Skip to content

Commit 1644ee7

Browse files
jacob-kellergregkh
authored andcommitted
ice: store max_frame and rx_buf_len only in ice_rx_ring
[ Upstream commit 7e61c89 ] The max_frame and rx_buf_len fields of the VSI set the maximum frame size for packets on the wire, and configure the size of the Rx buffer. In the hardware, these are per-queue configuration. Most VSI types use a simple method to determine the size of the buffers for all queues. However, VFs may potentially configure different values for each queue. While the Linux iAVF driver does not do this, it is allowed by the virtchnl interface. The current virtchnl code simply sets the per-VSI fields inbetween calls to ice_vsi_cfg_single_rxq(). This technically works, as these fields are only ever used when programming the Rx ring, and otherwise not checked again. However, it is confusing to maintain. The Rx ring also already has an rx_buf_len field in order to access the buffer length in the hotpath. It also has extra unused bytes in the ring structure which we can make use of to store the maximum frame size. Drop the VSI max_frame and rx_buf_len fields. Add max_frame to the Rx ring, and slightly re-order rx_buf_len to better fit into the gaps in the structure layout. Change the ice_vsi_cfg_frame_size function so that it writes to the ring fields. Call this function once per ring in ice_vsi_cfg_rxqs(). This is done over calling it inside the ice_vsi_cfg_rxq(), because ice_vsi_cfg_rxq() is called in the virtchnl flow where the max_frame and rx_buf_len have already been configured. Change the accesses for rx_buf_len and max_frame to all point to the ring structure. This has the added benefit that ice_vsi_cfg_rxq() no longer has the surprise side effect of updating ring->rx_buf_len based on the VSI field. Update the virtchnl ice_vc_cfg_qs_msg() function to set the ring values directly, and drop references to the removed VSI fields. This now makes the VF logic clear, as the ring fields are obviously per-queue. This reduces the required cognitive load when reasoning about this logic. Note that removing the VSI fields does leave a 4 byte gap, but the ice_vsi structure has many gaps, and its layout is not as critical in the hot path. The structure may benefit from a more thorough repacking, but no attempt was made in this change. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Stable-dep-of: 84bf1ac ("ice: fix Rx page leak on multi-buffer frames") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3e3be7b commit 1644ee7

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ struct ice_vsi {
372372
spinlock_t arfs_lock; /* protects aRFS hash table and filter state */
373373
atomic_t *arfs_last_fltr_id;
374374

375-
u16 max_frame;
376-
u16 rx_buf_len;
377-
378375
struct ice_aqc_vsi_props info; /* VSI properties */
379376
struct ice_vsi_vlan_info vlan_info; /* vlan config to be restored */
380377

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)
445445
/* Max packet size for this queue - must not be set to a larger value
446446
* than 5 x DBUF
447447
*/
448-
rlan_ctx.rxmax = min_t(u32, vsi->max_frame,
448+
rlan_ctx.rxmax = min_t(u32, ring->max_frame,
449449
ICE_MAX_CHAINED_RX_BUFS * ring->rx_buf_len);
450450

451451
/* Rx queue threshold in units of 64 */
@@ -541,8 +541,6 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
541541
u32 num_bufs = ICE_RX_DESC_UNUSED(ring);
542542
int err;
543543

544-
ring->rx_buf_len = ring->vsi->rx_buf_len;
545-
546544
if (ring->vsi->type == ICE_VSI_PF || ring->vsi->type == ICE_VSI_SF) {
547545
if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) {
548546
err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
@@ -641,21 +639,25 @@ int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx)
641639
/**
642640
* ice_vsi_cfg_frame_size - setup max frame size and Rx buffer length
643641
* @vsi: VSI
642+
* @ring: Rx ring to configure
643+
*
644+
* Determine the maximum frame size and Rx buffer length to use for a PF VSI.
645+
* Set these in the associated Rx ring structure.
644646
*/
645-
static void ice_vsi_cfg_frame_size(struct ice_vsi *vsi)
647+
static void ice_vsi_cfg_frame_size(struct ice_vsi *vsi, struct ice_rx_ring *ring)
646648
{
647649
if (!vsi->netdev || test_bit(ICE_FLAG_LEGACY_RX, vsi->back->flags)) {
648-
vsi->max_frame = ICE_MAX_FRAME_LEGACY_RX;
649-
vsi->rx_buf_len = ICE_RXBUF_1664;
650+
ring->max_frame = ICE_MAX_FRAME_LEGACY_RX;
651+
ring->rx_buf_len = ICE_RXBUF_1664;
650652
#if (PAGE_SIZE < 8192)
651653
} else if (!ICE_2K_TOO_SMALL_WITH_PADDING &&
652654
(vsi->netdev->mtu <= ETH_DATA_LEN)) {
653-
vsi->max_frame = ICE_RXBUF_1536 - NET_IP_ALIGN;
654-
vsi->rx_buf_len = ICE_RXBUF_1536 - NET_IP_ALIGN;
655+
ring->max_frame = ICE_RXBUF_1536 - NET_IP_ALIGN;
656+
ring->rx_buf_len = ICE_RXBUF_1536 - NET_IP_ALIGN;
655657
#endif
656658
} else {
657-
vsi->max_frame = ICE_AQ_SET_MAC_FRAME_SIZE_MAX;
658-
vsi->rx_buf_len = ICE_RXBUF_3072;
659+
ring->max_frame = ICE_AQ_SET_MAC_FRAME_SIZE_MAX;
660+
ring->rx_buf_len = ICE_RXBUF_3072;
659661
}
660662
}
661663

@@ -670,15 +672,15 @@ int ice_vsi_cfg_rxqs(struct ice_vsi *vsi)
670672
{
671673
u16 i;
672674

673-
if (vsi->type == ICE_VSI_VF)
674-
goto setup_rings;
675-
676-
ice_vsi_cfg_frame_size(vsi);
677-
setup_rings:
678675
/* set up individual rings */
679676
ice_for_each_rxq(vsi, i) {
680-
int err = ice_vsi_cfg_rxq(vsi->rx_rings[i]);
677+
struct ice_rx_ring *ring = vsi->rx_rings[i];
678+
int err;
679+
680+
if (vsi->type != ICE_VSI_VF)
681+
ice_vsi_cfg_frame_size(vsi, ring);
681682

683+
err = ice_vsi_cfg_rxq(ring);
682684
if (err)
683685
return err;
684686
}

drivers/net/ethernet/intel/ice/ice_txrx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,9 @@ struct ice_rx_ring {
358358
struct ice_rx_ring *next; /* pointer to next ring in q_vector */
359359
struct xsk_buff_pool *xsk_pool;
360360
u32 nr_frags;
361-
dma_addr_t dma; /* physical address of ring */
361+
u16 max_frame;
362362
u16 rx_buf_len;
363+
dma_addr_t dma; /* physical address of ring */
363364
u8 dcb_tc; /* Traffic class of ring */
364365
u8 ptp_rx;
365366
#define ICE_RX_FLAGS_RING_BUILD_SKB BIT(1)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,19 +1748,18 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
17481748
(qpi->rxq.databuffer_size > ((16 * 1024) - 128) ||
17491749
qpi->rxq.databuffer_size < 1024))
17501750
goto error_param;
1751-
vsi->rx_buf_len = qpi->rxq.databuffer_size;
1752-
ring->rx_buf_len = vsi->rx_buf_len;
1751+
ring->rx_buf_len = qpi->rxq.databuffer_size;
17531752
if (qpi->rxq.max_pkt_size > max_frame_size ||
17541753
qpi->rxq.max_pkt_size < 64)
17551754
goto error_param;
17561755

1757-
vsi->max_frame = qpi->rxq.max_pkt_size;
1756+
ring->max_frame = qpi->rxq.max_pkt_size;
17581757
/* add space for the port VLAN since the VF driver is
17591758
* not expected to account for it in the MTU
17601759
* calculation
17611760
*/
17621761
if (ice_vf_is_port_vlan_ena(vf))
1763-
vsi->max_frame += VLAN_HLEN;
1762+
ring->max_frame += VLAN_HLEN;
17641763

17651764
if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
17661765
dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure RX queue %d\n",

0 commit comments

Comments
 (0)