@@ -703,8 +703,10 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
703703{
704704 struct idpf_adapter * adapter = vport -> adapter ;
705705 struct idpf_vport_config * vport_config ;
706+ netdev_features_t other_offloads = 0 ;
707+ netdev_features_t csum_offloads = 0 ;
708+ netdev_features_t tso_offloads = 0 ;
706709 netdev_features_t dflt_features ;
707- netdev_features_t offloads = 0 ;
708710 struct idpf_netdev_priv * np ;
709711 struct net_device * netdev ;
710712 u16 idx = vport -> idx ;
@@ -721,6 +723,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
721723 np -> vport = vport ;
722724 np -> vport_idx = vport -> idx ;
723725 np -> vport_id = vport -> vport_id ;
726+ np -> max_tx_hdr_size = idpf_get_max_tx_hdr_size (adapter );
724727 vport -> netdev = netdev ;
725728
726729 return idpf_init_mac_addr (vport , netdev );
@@ -738,6 +741,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
738741 np -> adapter = adapter ;
739742 np -> vport_idx = vport -> idx ;
740743 np -> vport_id = vport -> vport_id ;
744+ np -> max_tx_hdr_size = idpf_get_max_tx_hdr_size (adapter );
741745
742746 spin_lock_init (& np -> stats_lock );
743747
@@ -766,53 +770,32 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
766770
767771 if (idpf_is_cap_ena_all (adapter , IDPF_RSS_CAPS , IDPF_CAP_RSS ))
768772 dflt_features |= NETIF_F_RXHASH ;
769- if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_RX_CSUM_L4V4 ))
770- dflt_features |= NETIF_F_IP_CSUM ;
771- if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_RX_CSUM_L4V6 ))
772- dflt_features |= NETIF_F_IPV6_CSUM ;
773+ if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_TX_CSUM_L4V4 ))
774+ csum_offloads |= NETIF_F_IP_CSUM ;
775+ if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_TX_CSUM_L4V6 ))
776+ csum_offloads |= NETIF_F_IPV6_CSUM ;
773777 if (idpf_is_cap_ena (adapter , IDPF_CSUM_CAPS , IDPF_CAP_RX_CSUM ))
774- dflt_features |= NETIF_F_RXCSUM ;
775- if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_SCTP_CSUM ))
776- dflt_features |= NETIF_F_SCTP_CRC ;
778+ csum_offloads |= NETIF_F_RXCSUM ;
779+ if (idpf_is_cap_ena_all (adapter , IDPF_CSUM_CAPS , IDPF_CAP_TX_SCTP_CSUM ))
780+ csum_offloads |= NETIF_F_SCTP_CRC ;
777781
778782 if (idpf_is_cap_ena (adapter , IDPF_SEG_CAPS , VIRTCHNL2_CAP_SEG_IPV4_TCP ))
779- dflt_features |= NETIF_F_TSO ;
783+ tso_offloads |= NETIF_F_TSO ;
780784 if (idpf_is_cap_ena (adapter , IDPF_SEG_CAPS , VIRTCHNL2_CAP_SEG_IPV6_TCP ))
781- dflt_features |= NETIF_F_TSO6 ;
785+ tso_offloads |= NETIF_F_TSO6 ;
782786 if (idpf_is_cap_ena_all (adapter , IDPF_SEG_CAPS ,
783787 VIRTCHNL2_CAP_SEG_IPV4_UDP |
784788 VIRTCHNL2_CAP_SEG_IPV6_UDP ))
785- dflt_features |= NETIF_F_GSO_UDP_L4 ;
789+ tso_offloads |= NETIF_F_GSO_UDP_L4 ;
786790 if (idpf_is_cap_ena_all (adapter , IDPF_RSC_CAPS , IDPF_CAP_RSC ))
787- offloads |= NETIF_F_GRO_HW ;
788- /* advertise to stack only if offloads for encapsulated packets is
789- * supported
790- */
791- if (idpf_is_cap_ena (vport -> adapter , IDPF_SEG_CAPS ,
792- VIRTCHNL2_CAP_SEG_TX_SINGLE_TUNNEL )) {
793- offloads |= NETIF_F_GSO_UDP_TUNNEL |
794- NETIF_F_GSO_GRE |
795- NETIF_F_GSO_GRE_CSUM |
796- NETIF_F_GSO_PARTIAL |
797- NETIF_F_GSO_UDP_TUNNEL_CSUM |
798- NETIF_F_GSO_IPXIP4 |
799- NETIF_F_GSO_IPXIP6 |
800- 0 ;
801-
802- if (!idpf_is_cap_ena_all (vport -> adapter , IDPF_CSUM_CAPS ,
803- IDPF_CAP_TUNNEL_TX_CSUM ))
804- netdev -> gso_partial_features |=
805- NETIF_F_GSO_UDP_TUNNEL_CSUM ;
806-
807- netdev -> gso_partial_features |= NETIF_F_GSO_GRE_CSUM ;
808- offloads |= NETIF_F_TSO_MANGLEID ;
809- }
791+ other_offloads |= NETIF_F_GRO_HW ;
810792 if (idpf_is_cap_ena (adapter , IDPF_OTHER_CAPS , VIRTCHNL2_CAP_LOOPBACK ))
811- offloads |= NETIF_F_LOOPBACK ;
793+ other_offloads |= NETIF_F_LOOPBACK ;
812794
813- netdev -> features |= dflt_features ;
814- netdev -> hw_features |= dflt_features | offloads ;
815- netdev -> hw_enc_features |= dflt_features | offloads ;
795+ netdev -> features |= dflt_features | csum_offloads | tso_offloads ;
796+ netdev -> hw_features |= netdev -> features | other_offloads ;
797+ netdev -> vlan_features |= netdev -> features | other_offloads ;
798+ netdev -> hw_enc_features |= dflt_features | other_offloads ;
816799 idpf_set_ethtool_ops (netdev );
817800 SET_NETDEV_DEV (netdev , & adapter -> pdev -> dev );
818801
@@ -927,15 +910,19 @@ static int idpf_stop(struct net_device *netdev)
927910static void idpf_decfg_netdev (struct idpf_vport * vport )
928911{
929912 struct idpf_adapter * adapter = vport -> adapter ;
913+ u16 idx = vport -> idx ;
930914
931915 kfree (vport -> rx_ptype_lkup );
932916 vport -> rx_ptype_lkup = NULL ;
933917
934- unregister_netdev (vport -> netdev );
935- free_netdev (vport -> netdev );
918+ if (test_and_clear_bit (IDPF_VPORT_REG_NETDEV ,
919+ adapter -> vport_config [idx ]-> flags )) {
920+ unregister_netdev (vport -> netdev );
921+ free_netdev (vport -> netdev );
922+ }
936923 vport -> netdev = NULL ;
937924
938- adapter -> netdevs [vport -> idx ] = NULL ;
925+ adapter -> netdevs [idx ] = NULL ;
939926}
940927
941928/**
@@ -1127,11 +1114,9 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
11271114
11281115 num_max_q = max (max_q -> max_txq , max_q -> max_rxq );
11291116 vport -> q_vector_idxs = kcalloc (num_max_q , sizeof (u16 ), GFP_KERNEL );
1130- if (!vport -> q_vector_idxs ) {
1131- kfree ( vport ) ;
1117+ if (!vport -> q_vector_idxs )
1118+ goto free_vport ;
11321119
1133- return NULL ;
1134- }
11351120 idpf_vport_init (vport , max_q );
11361121
11371122 /* This alloc is done separate from the LUT because it's not strictly
@@ -1141,11 +1126,9 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
11411126 */
11421127 rss_data = & adapter -> vport_config [idx ]-> user_config .rss_data ;
11431128 rss_data -> rss_key = kzalloc (rss_data -> rss_key_size , GFP_KERNEL );
1144- if (!rss_data -> rss_key ) {
1145- kfree ( vport ) ;
1129+ if (!rss_data -> rss_key )
1130+ goto free_vector_idxs ;
11461131
1147- return NULL ;
1148- }
11491132 /* Initialize default rss key */
11501133 netdev_rss_key_fill ((void * )rss_data -> rss_key , rss_data -> rss_key_size );
11511134
@@ -1158,6 +1141,13 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
11581141 adapter -> next_vport = idpf_get_free_slot (adapter );
11591142
11601143 return vport ;
1144+
1145+ free_vector_idxs :
1146+ kfree (vport -> q_vector_idxs );
1147+ free_vport :
1148+ kfree (vport );
1149+
1150+ return NULL ;
11611151}
11621152
11631153/**
@@ -1536,13 +1526,22 @@ void idpf_init_task(struct work_struct *work)
15361526 }
15371527
15381528 for (index = 0 ; index < adapter -> max_vports ; index ++ ) {
1539- if (adapter -> netdevs [index ] &&
1540- !test_bit (IDPF_VPORT_REG_NETDEV ,
1541- adapter -> vport_config [index ]-> flags )) {
1542- register_netdev (adapter -> netdevs [index ]);
1543- set_bit (IDPF_VPORT_REG_NETDEV ,
1544- adapter -> vport_config [index ]-> flags );
1529+ struct net_device * netdev = adapter -> netdevs [index ];
1530+ struct idpf_vport_config * vport_config ;
1531+
1532+ vport_config = adapter -> vport_config [index ];
1533+
1534+ if (!netdev ||
1535+ test_bit (IDPF_VPORT_REG_NETDEV , vport_config -> flags ))
1536+ continue ;
1537+
1538+ err = register_netdev (netdev );
1539+ if (err ) {
1540+ dev_err (& pdev -> dev , "failed to register netdev for vport %d: %pe\n" ,
1541+ index , ERR_PTR (err ));
1542+ continue ;
15451543 }
1544+ set_bit (IDPF_VPORT_REG_NETDEV , vport_config -> flags );
15461545 }
15471546
15481547 /* As all the required vports are created, clear the reset flag
@@ -2205,8 +2204,8 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22052204 struct net_device * netdev ,
22062205 netdev_features_t features )
22072206{
2208- struct idpf_vport * vport = idpf_netdev_to_vport (netdev );
2209- struct idpf_adapter * adapter = vport -> adapter ;
2207+ struct idpf_netdev_priv * np = netdev_priv (netdev );
2208+ u16 max_tx_hdr_size = np -> max_tx_hdr_size ;
22102209 size_t len ;
22112210
22122211 /* No point in doing any of this if neither checksum nor GSO are
@@ -2229,7 +2228,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22292228 goto unsupported ;
22302229
22312230 len = skb_network_header_len (skb );
2232- if (unlikely (len > idpf_get_max_tx_hdr_size ( adapter ) ))
2231+ if (unlikely (len > max_tx_hdr_size ))
22332232 goto unsupported ;
22342233
22352234 if (!skb -> encapsulation )
@@ -2242,7 +2241,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22422241
22432242 /* IPLEN can support at most 127 dwords */
22442243 len = skb_inner_network_header_len (skb );
2245- if (unlikely (len > idpf_get_max_tx_hdr_size ( adapter ) ))
2244+ if (unlikely (len > max_tx_hdr_size ))
22462245 goto unsupported ;
22472246
22482247 /* No need to validate L4LEN as TCP is the only protocol with a
0 commit comments