Skip to content

Commit 2a86e21

Browse files
jacob-kelleranguy11
authored andcommitted
iavf: add support for negotiating flexible RXDID format
Enable support for VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC, to enable the VF driver the ability to determine what Rx descriptor formats are available. This requires sending an additional message during initialization and reset, the VIRTCHNL_OP_GET_SUPPORTED_RXDIDS. This operation requests the supported Rx descriptor IDs available from the PF. This is treated the same way that VLAN V2 capabilities are handled. Add a new set of extended capability flags, used to process send and receipt of the VIRTCHNL_OP_GET_SUPPORTED_RXDIDS message. This ensures we finish negotiating for the supported descriptor formats prior to beginning configuration of receive queues. This change stores the supported format bitmap into the iavf_adapter structure. Additionally, if VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is enabled by the PF, we need to make sure that the Rx queue configuration specifies the format. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Co-developed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 6a88c79 commit 2a86e21

File tree

6 files changed

+178
-16
lines changed

6 files changed

+178
-16
lines changed

drivers/net/ethernet/intel/iavf/iavf.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ struct iavf_adapter {
271271
/* Lock to protect accesses to MAC and VLAN lists */
272272
spinlock_t mac_vlan_list_lock;
273273
char misc_vector_name[IFNAMSIZ + 9];
274+
u8 rxdid;
274275
int num_active_queues;
275276
int num_req_queues;
276277

@@ -343,6 +344,14 @@ struct iavf_adapter {
343344
#define IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW BIT_ULL(39)
344345
#define IAVF_FLAG_AQ_CFG_QUEUES_QUANTA_SIZE BIT_ULL(40)
345346
#define IAVF_FLAG_AQ_GET_QOS_CAPS BIT_ULL(41)
347+
#define IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS BIT_ULL(42)
348+
349+
/* AQ messages that must be sent after IAVF_FLAG_AQ_GET_CONFIG, in
350+
* order to negotiated extended capabilities.
351+
*/
352+
#define IAVF_FLAG_AQ_EXTENDED_CAPS \
353+
(IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS | \
354+
IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS)
346355

347356
/* flags for processing extended capability messages during
348357
* __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
@@ -354,10 +363,14 @@ struct iavf_adapter {
354363
u64 extended_caps;
355364
#define IAVF_EXTENDED_CAP_SEND_VLAN_V2 BIT_ULL(0)
356365
#define IAVF_EXTENDED_CAP_RECV_VLAN_V2 BIT_ULL(1)
366+
#define IAVF_EXTENDED_CAP_SEND_RXDID BIT_ULL(2)
367+
#define IAVF_EXTENDED_CAP_RECV_RXDID BIT_ULL(3)
357368

358369
#define IAVF_EXTENDED_CAPS \
359370
(IAVF_EXTENDED_CAP_SEND_VLAN_V2 | \
360-
IAVF_EXTENDED_CAP_RECV_VLAN_V2)
371+
IAVF_EXTENDED_CAP_RECV_VLAN_V2 | \
372+
IAVF_EXTENDED_CAP_SEND_RXDID | \
373+
IAVF_EXTENDED_CAP_RECV_RXDID)
361374

362375
/* Lock to prevent possible clobbering of
363376
* current_netdev_promisc_flags
@@ -417,12 +430,15 @@ struct iavf_adapter {
417430
VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)
418431
#define QOS_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
419432
VIRTCHNL_VF_OFFLOAD_QOS)
433+
#define IAVF_RXDID_ALLOWED(a) \
434+
((a)->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
420435
struct virtchnl_vf_resource *vf_res; /* incl. all VSIs */
421436
struct virtchnl_vsi_resource *vsi_res; /* our LAN VSI */
422437
struct virtchnl_version_info pf_version;
423438
#define PF_IS_V11(_a) (((_a)->pf_version.major == 1) && \
424439
((_a)->pf_version.minor == 1))
425440
struct virtchnl_vlan_caps vlan_v2_caps;
441+
u64 supp_rxdids;
426442
u16 msg_enable;
427443
struct iavf_eth_stats current_stats;
428444
struct virtchnl_qos_cap_list *qos_caps;
@@ -555,6 +571,8 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter);
555571
int iavf_get_vf_config(struct iavf_adapter *adapter);
556572
int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter);
557573
int iavf_send_vf_offload_vlan_v2_msg(struct iavf_adapter *adapter);
574+
int iavf_send_vf_supported_rxdids_msg(struct iavf_adapter *adapter);
575+
int iavf_get_vf_supported_rxdids(struct iavf_adapter *adapter);
558576
void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter);
559577
u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter);
560578
void iavf_irq_enable(struct iavf_adapter *adapter, bool flush);

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 115 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

drivers/net/ethernet/intel/iavf/iavf_txrx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ struct iavf_ring {
262262
u16 next_to_use;
263263
u16 next_to_clean;
264264

265+
u16 rxdid; /* Rx descriptor format */
266+
265267
u16 flags;
266268
#define IAVF_TXR_FLAGS_WB_ON_ITR BIT(0)
267269
#define IAVF_TXR_FLAGS_ARM_WB BIT(1)

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
144144
VIRTCHNL_VF_OFFLOAD_ENCAP |
145145
VIRTCHNL_VF_OFFLOAD_TC_U32 |
146146
VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
147+
VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
147148
VIRTCHNL_VF_OFFLOAD_CRC |
148149
VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
149150
VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
@@ -177,6 +178,19 @@ int iavf_send_vf_offload_vlan_v2_msg(struct iavf_adapter *adapter)
177178
NULL, 0);
178179
}
179180

181+
int iavf_send_vf_supported_rxdids_msg(struct iavf_adapter *adapter)
182+
{
183+
adapter->aq_required &= ~IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS;
184+
185+
if (!IAVF_RXDID_ALLOWED(adapter))
186+
return -EOPNOTSUPP;
187+
188+
adapter->current_op = VIRTCHNL_OP_GET_SUPPORTED_RXDIDS;
189+
190+
return iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_SUPPORTED_RXDIDS,
191+
NULL, 0);
192+
}
193+
180194
/**
181195
* iavf_validate_num_queues
182196
* @adapter: adapter structure
@@ -263,6 +277,23 @@ int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter)
263277
return err;
264278
}
265279

280+
int iavf_get_vf_supported_rxdids(struct iavf_adapter *adapter)
281+
{
282+
struct iavf_arq_event_info event;
283+
u64 rxdids;
284+
int err;
285+
286+
event.msg_buf = (u8 *)&rxdids;
287+
event.buf_len = sizeof(rxdids);
288+
289+
err = iavf_poll_virtchnl_msg(&adapter->hw, &event,
290+
VIRTCHNL_OP_GET_SUPPORTED_RXDIDS);
291+
if (!err)
292+
adapter->supp_rxdids = rxdids;
293+
294+
return err;
295+
}
296+
266297
/**
267298
* iavf_configure_queues
268299
* @adapter: adapter structure
@@ -309,6 +340,8 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
309340
vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
310341
vqpi->rxq.max_pkt_size = max_frame;
311342
vqpi->rxq.databuffer_size = adapter->rx_rings[i].rx_buf_len;
343+
if (IAVF_RXDID_ALLOWED(adapter))
344+
vqpi->rxq.rxdid = adapter->rxdid;
312345
if (CRC_OFFLOAD_ALLOWED(adapter))
313346
vqpi->rxq.crc_disable = !!(adapter->netdev->features &
314347
NETIF_F_RXFCS);
@@ -2508,6 +2541,13 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
25082541
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER |
25092542
aq_required;
25102543
}
2544+
break;
2545+
case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
2546+
if (msglen != sizeof(u64))
2547+
return;
2548+
2549+
adapter->supp_rxdids = *(u64 *)msg;
2550+
25112551
break;
25122552
case VIRTCHNL_OP_ENABLE_QUEUES:
25132553
/* enable transmits */

drivers/net/ethernet/intel/ice/ice_virtchnl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,8 +3040,8 @@ static int ice_vc_set_rss_hena(struct ice_vf *vf, u8 *msg)
30403040
static int ice_vc_query_rxdid(struct ice_vf *vf)
30413041
{
30423042
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
3043-
struct virtchnl_supported_rxdids rxdid = {};
30443043
struct ice_pf *pf = vf->pf;
3044+
u64 rxdid;
30453045

30463046
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
30473047
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -3053,7 +3053,7 @@ static int ice_vc_query_rxdid(struct ice_vf *vf)
30533053
goto err;
30543054
}
30553055

3056-
rxdid.supported_rxdids = pf->supported_rxdids;
3056+
rxdid = pf->supported_rxdids;
30573057

30583058
err:
30593059
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_GET_SUPPORTED_RXDIDS,

include/linux/avf/virtchnl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,6 @@ struct virtchnl_filter {
10961096

10971097
VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
10981098

1099-
struct virtchnl_supported_rxdids {
1100-
/* see enum virtchnl_rx_desc_id_bitmasks */
1101-
u64 supported_rxdids;
1102-
};
1103-
11041099
/* VIRTCHNL_OP_EVENT
11051100
* PF sends this message to inform the VF driver of events that may affect it.
11061101
* No direct response is expected from the VF, though it may generate other

0 commit comments

Comments
 (0)