@@ -709,6 +709,38 @@ static void iavf_configure_tx(struct iavf_adapter *adapter)
709709 adapter -> tx_rings [i ].tail = hw -> hw_addr + IAVF_QTX_TAIL1 (i );
710710}
711711
712+ /**
713+ * iavf_select_rx_desc_format - Select Rx descriptor format
714+ * @adapter: adapter private structure
715+ *
716+ * Select what Rx descriptor format based on availability and enabled
717+ * features.
718+ *
719+ * Return: the desired RXDID to select for a given Rx queue, as defined by
720+ * enum virtchnl_rxdid_format.
721+ */
722+ static u8 iavf_select_rx_desc_format (const struct iavf_adapter * adapter )
723+ {
724+ u64 rxdids = adapter -> supp_rxdids ;
725+
726+ /* If we did not negotiate VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC, we must
727+ * stick with the default value of the legacy 32 byte format.
728+ */
729+ if (!IAVF_RXDID_ALLOWED (adapter ))
730+ return VIRTCHNL_RXDID_1_32B_BASE ;
731+
732+ /* Warn if the PF does not list support for the default legacy
733+ * descriptor format. This shouldn't happen, as this is the format
734+ * used if VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is not supported. It is
735+ * likely caused by a bug in the PF implementation failing to indicate
736+ * support for the format.
737+ */
738+ if (!(rxdids & VIRTCHNL_RXDID_1_32B_BASE_M ))
739+ netdev_warn (adapter -> netdev , "PF does not list support for default Rx descriptor format\n" );
740+
741+ return VIRTCHNL_RXDID_1_32B_BASE ;
742+ }
743+
712744/**
713745 * iavf_configure_rx - Configure Receive Unit after Reset
714746 * @adapter: board private structure
@@ -719,8 +751,12 @@ static void iavf_configure_rx(struct iavf_adapter *adapter)
719751{
720752 struct iavf_hw * hw = & adapter -> hw ;
721753
722- for (u32 i = 0 ; i < adapter -> num_active_queues ; i ++ )
754+ adapter -> rxdid = iavf_select_rx_desc_format (adapter );
755+
756+ for (u32 i = 0 ; i < adapter -> num_active_queues ; i ++ ) {
723757 adapter -> rx_rings [i ].tail = hw -> hw_addr + IAVF_QRX_TAIL1 (i );
758+ adapter -> rx_rings [i ].rxdid = adapter -> rxdid ;
759+ }
724760}
725761
726762/**
@@ -2071,6 +2107,8 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
20712107 return iavf_send_vf_config_msg (adapter );
20722108 if (adapter -> aq_required & IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS )
20732109 return iavf_send_vf_offload_vlan_v2_msg (adapter );
2110+ if (adapter -> aq_required & IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS )
2111+ return iavf_send_vf_supported_rxdids_msg (adapter );
20742112 if (adapter -> aq_required & IAVF_FLAG_AQ_DISABLE_QUEUES ) {
20752113 iavf_disable_queues (adapter );
20762114 return 0 ;
@@ -2599,6 +2637,63 @@ static void iavf_init_recv_offload_vlan_v2_caps(struct iavf_adapter *adapter)
25992637 iavf_change_state (adapter , __IAVF_INIT_FAILED );
26002638}
26012639
2640+ /**
2641+ * iavf_init_send_supported_rxdids - part of querying for supported RXDID
2642+ * formats
2643+ * @adapter: board private structure
2644+ *
2645+ * Function processes send of the request for supported RXDIDs to the PF.
2646+ * Must clear IAVF_EXTENDED_CAP_RECV_RXDID if the message is not sent, e.g.
2647+ * due to the PF not negotiating VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC.
2648+ */
2649+ static void iavf_init_send_supported_rxdids (struct iavf_adapter * adapter )
2650+ {
2651+ int ret ;
2652+
2653+ ret = iavf_send_vf_supported_rxdids_msg (adapter );
2654+ if (ret == - EOPNOTSUPP ) {
2655+ /* PF does not support VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC. In this
2656+ * case, we did not send the capability exchange message and
2657+ * do not expect a response.
2658+ */
2659+ adapter -> extended_caps &= ~IAVF_EXTENDED_CAP_RECV_RXDID ;
2660+ }
2661+
2662+ /* We sent the message, so move on to the next step */
2663+ adapter -> extended_caps &= ~IAVF_EXTENDED_CAP_SEND_RXDID ;
2664+ }
2665+
2666+ /**
2667+ * iavf_init_recv_supported_rxdids - part of querying for supported RXDID
2668+ * formats
2669+ * @adapter: board private structure
2670+ *
2671+ * Function processes receipt of the supported RXDIDs message from the PF.
2672+ **/
2673+ static void iavf_init_recv_supported_rxdids (struct iavf_adapter * adapter )
2674+ {
2675+ int ret ;
2676+
2677+ memset (& adapter -> supp_rxdids , 0 , sizeof (adapter -> supp_rxdids ));
2678+
2679+ ret = iavf_get_vf_supported_rxdids (adapter );
2680+ if (ret )
2681+ goto err ;
2682+
2683+ /* We've processed the PF response to the
2684+ * VIRTCHNL_OP_GET_SUPPORTED_RXDIDS message we sent previously.
2685+ */
2686+ adapter -> extended_caps &= ~IAVF_EXTENDED_CAP_RECV_RXDID ;
2687+ return ;
2688+
2689+ err :
2690+ /* We didn't receive a reply. Make sure we try sending again when
2691+ * __IAVF_INIT_FAILED attempts to recover.
2692+ */
2693+ adapter -> extended_caps |= IAVF_EXTENDED_CAP_SEND_RXDID ;
2694+ iavf_change_state (adapter , __IAVF_INIT_FAILED );
2695+ }
2696+
26022697/**
26032698 * iavf_init_process_extended_caps - Part of driver startup
26042699 * @adapter: board private structure
@@ -2623,6 +2718,15 @@ static void iavf_init_process_extended_caps(struct iavf_adapter *adapter)
26232718 return ;
26242719 }
26252720
2721+ /* Process capability exchange for RXDID formats */
2722+ if (adapter -> extended_caps & IAVF_EXTENDED_CAP_SEND_RXDID ) {
2723+ iavf_init_send_supported_rxdids (adapter );
2724+ return ;
2725+ } else if (adapter -> extended_caps & IAVF_EXTENDED_CAP_RECV_RXDID ) {
2726+ iavf_init_recv_supported_rxdids (adapter );
2727+ return ;
2728+ }
2729+
26262730 /* When we reach here, no further extended capabilities exchanges are
26272731 * necessary, so we finally transition into __IAVF_INIT_CONFIG_ADAPTER
26282732 */
@@ -3139,15 +3243,18 @@ static void iavf_reset_task(struct work_struct *work)
31393243 }
31403244
31413245 adapter -> aq_required |= IAVF_FLAG_AQ_GET_CONFIG ;
3142- /* always set since VIRTCHNL_OP_GET_VF_RESOURCES has not been
3143- * sent/received yet, so VLAN_V2_ALLOWED() cannot is not reliable here,
3144- * however the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS won't be sent until
3145- * VIRTCHNL_OP_GET_VF_RESOURCES and VIRTCHNL_VF_OFFLOAD_VLAN_V2 have
3146- * been successfully sent and negotiated
3147- */
3148- adapter -> aq_required |= IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS ;
31493246 adapter -> aq_required |= IAVF_FLAG_AQ_MAP_VECTORS ;
31503247
3248+ /* Certain capabilities require an extended negotiation process using
3249+ * extra messages that must be processed after getting the VF
3250+ * configuration. The related checks such as VLAN_V2_ALLOWED() are not
3251+ * reliable here, since the configuration has not yet been negotiated.
3252+ *
3253+ * Always set these flags, since them related VIRTCHNL messages won't
3254+ * be sent until after VIRTCHNL_OP_GET_VF_RESOURCES.
3255+ */
3256+ adapter -> aq_required |= IAVF_FLAG_AQ_EXTENDED_CAPS ;
3257+
31513258 spin_lock_bh (& adapter -> mac_vlan_list_lock );
31523259
31533260 /* Delete filter for the current MAC address, it could have
0 commit comments