Skip to content

Commit f96e1b3

Browse files
committed
eth: bnxt: support qcfg provided rx page size
Implement support for qcfg provided rx page sizes. For that, implement the ndo_default_qcfg callback and validate the config on restart. Also, use the current config's value in bnxt_init_ring_struct to retain the correct size across resets. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent c55bf90 commit f96e1b3

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4331,6 +4331,7 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
43314331
struct bnxt_rx_ring_info *rxr;
43324332
struct bnxt_tx_ring_info *txr;
43334333
struct bnxt_ring_struct *ring;
4334+
struct netdev_rx_queue *rxq;
43344335

43354336
if (!bnapi)
43364337
continue;
@@ -4348,7 +4349,8 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
43484349
if (!rxr)
43494350
goto skip_rx;
43504351

4351-
rxr->rx_page_size = BNXT_RX_PAGE_SIZE;
4352+
rxq = __netif_get_rx_queue(bp->dev, i);
4353+
rxr->rx_page_size = rxq->qcfg.rx_page_size;
43524354

43534355
ring = &rxr->rx_ring_struct;
43544356
rmem = &ring->ring_mem;
@@ -15938,6 +15940,29 @@ static const struct netdev_stat_ops bnxt_stat_ops = {
1593815940
.get_base_stats = bnxt_get_base_stats,
1593915941
};
1594015942

15943+
static void bnxt_queue_default_qcfg(struct net_device *dev,
15944+
struct netdev_queue_config *qcfg)
15945+
{
15946+
qcfg->rx_page_size = BNXT_RX_PAGE_SIZE;
15947+
}
15948+
15949+
static int bnxt_validate_qcfg(struct bnxt *bp, struct netdev_queue_config *qcfg)
15950+
{
15951+
/* Older chips need MSS calc so rx_page_size is not supported */
15952+
if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) &&
15953+
qcfg->rx_page_size != BNXT_RX_PAGE_SIZE)
15954+
return -EINVAL;
15955+
15956+
if (!is_power_of_2(qcfg->rx_page_size))
15957+
return -ERANGE;
15958+
15959+
if (qcfg->rx_page_size < BNXT_RX_PAGE_SIZE ||
15960+
qcfg->rx_page_size > BNXT_MAX_RX_PAGE_SIZE)
15961+
return -ERANGE;
15962+
15963+
return 0;
15964+
}
15965+
1594115966
static int bnxt_queue_mem_alloc(struct net_device *dev,
1594215967
struct netdev_queue_config *qcfg,
1594315968
void *qmem, int idx)
@@ -15950,6 +15975,10 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
1595015975
if (!bp->rx_ring)
1595115976
return -ENETDOWN;
1595215977

15978+
rc = bnxt_validate_qcfg(bp, qcfg);
15979+
if (rc < 0)
15980+
return rc;
15981+
1595315982
rxr = &bp->rx_ring[idx];
1595415983
clone = qmem;
1595515984
memcpy(clone, rxr, sizeof(*rxr));
@@ -15961,6 +15990,7 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
1596115990
clone->rx_sw_agg_prod = 0;
1596215991
clone->rx_next_cons = 0;
1596315992
clone->need_head_pool = false;
15993+
clone->rx_page_size = qcfg->rx_page_size;
1596415994

1596515995
rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid);
1596615996
if (rc)
@@ -16087,6 +16117,8 @@ static void bnxt_copy_rx_ring(struct bnxt *bp,
1608716117
src_ring = &src->rx_agg_ring_struct;
1608816118
src_rmem = &src_ring->ring_mem;
1608916119

16120+
dst->rx_page_size = src->rx_page_size;
16121+
1609016122
WARN_ON(dst_rmem->nr_pages != src_rmem->nr_pages);
1609116123
WARN_ON(dst_rmem->page_size != src_rmem->page_size);
1609216124
WARN_ON(dst_rmem->flags != src_rmem->flags);
@@ -16241,6 +16273,8 @@ static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops = {
1624116273
.ndo_queue_mem_free = bnxt_queue_mem_free,
1624216274
.ndo_queue_start = bnxt_queue_start,
1624316275
.ndo_queue_stop = bnxt_queue_stop,
16276+
.ndo_default_qcfg = bnxt_queue_default_qcfg,
16277+
.supported_params = QCFG_RX_PAGE_SIZE,
1624416278
};
1624516279

1624616280
static void bnxt_remove_one(struct pci_dev *pdev)

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ struct nqe_cn {
760760
#endif
761761

762762
#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
763+
#define BNXT_MAX_RX_PAGE_SIZE BIT(15)
763764

764765
#define BNXT_MAX_MTU 9500
765766

0 commit comments

Comments
 (0)