Skip to content

Commit d4d0249

Browse files
committed
Merge tag 'mlx5-updates-2017-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2017-06-23 This series provides some updates to the mlx5 core and netdevice drivers. Three patches from Tariq, Introduces page reuse mechanism in non-Striding RQ RX datapath, we allow the the RX descriptor to reuse its allocated page as much as it could, until the page is fully consumed. RX page reuse reduces the stress on page allocator and improves RX performance especially with high speeds (100Gb/s). Next four patches of the series from Or allows to offload tc flower matching on ttl/hoplimit and header re-write of hoplimit. The rest of the series from Yotam and Or enhances mlx5 to support FW flashing through the mlxfw module, in a similar manner done by the mlxsw driver. Currently, only ethtool based flashing is implemented, where both Eth and IB ports are supported. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 8f46d46 + 137ffd1 commit d4d0249

File tree

14 files changed

+634
-101
lines changed

14 files changed

+634
-101
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW 0x6
7373

7474
#define MLX5_RX_HEADROOM NET_SKB_PAD
75+
#define MLX5_SKB_FRAG_SZ(len) (SKB_DATA_ALIGN(len) + \
76+
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
7577

7678
#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \
7779
(6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */
@@ -215,6 +217,7 @@ struct mlx5e_cq_moder {
215217
struct mlx5e_params {
216218
u8 log_sq_size;
217219
u8 rq_wq_type;
220+
u16 rq_headroom;
218221
u8 mpwqe_log_stride_sz;
219222
u8 mpwqe_log_num_strides;
220223
u8 log_rq_size;
@@ -445,6 +448,11 @@ struct mlx5e_dma_info {
445448
dma_addr_t addr;
446449
};
447450

451+
struct mlx5e_wqe_frag_info {
452+
struct mlx5e_dma_info di;
453+
u32 offset;
454+
};
455+
448456
struct mlx5e_umr_dma_info {
449457
__be64 *mtt;
450458
dma_addr_t mtt_addr;
@@ -506,7 +514,12 @@ struct mlx5e_rq {
506514
struct mlx5_wq_ll wq;
507515

508516
union {
509-
struct mlx5e_dma_info *dma_info;
517+
struct {
518+
struct mlx5e_wqe_frag_info *frag_info;
519+
u32 frag_sz; /* max possible skb frag_sz */
520+
bool page_reuse;
521+
bool xdp_xmit;
522+
} wqe;
510523
struct {
511524
struct mlx5e_mpw_info *info;
512525
void *mtt_no_align;
@@ -1047,6 +1060,8 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
10471060
struct ethtool_coalesce *coal);
10481061
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
10491062
struct ethtool_ts_info *info);
1063+
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
1064+
struct ethtool_flash *flash);
10501065

10511066
/* mlx5e generic netdev management API */
10521067
struct net_device*

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,40 @@ static int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
17951795
return err;
17961796
}
17971797

1798+
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
1799+
struct ethtool_flash *flash)
1800+
{
1801+
struct mlx5_core_dev *mdev = priv->mdev;
1802+
struct net_device *dev = priv->netdev;
1803+
const struct firmware *fw;
1804+
int err;
1805+
1806+
if (flash->region != ETHTOOL_FLASH_ALL_REGIONS)
1807+
return -EOPNOTSUPP;
1808+
1809+
err = request_firmware_direct(&fw, flash->data, &dev->dev);
1810+
if (err)
1811+
return err;
1812+
1813+
dev_hold(dev);
1814+
rtnl_unlock();
1815+
1816+
err = mlx5_firmware_flash(mdev, fw);
1817+
release_firmware(fw);
1818+
1819+
rtnl_lock();
1820+
dev_put(dev);
1821+
return err;
1822+
}
1823+
1824+
static int mlx5e_flash_device(struct net_device *dev,
1825+
struct ethtool_flash *flash)
1826+
{
1827+
struct mlx5e_priv *priv = netdev_priv(dev);
1828+
1829+
return mlx5e_ethtool_flash_device(priv, flash);
1830+
}
1831+
17981832
const struct ethtool_ops mlx5e_ethtool_ops = {
17991833
.get_drvinfo = mlx5e_get_drvinfo,
18001834
.get_link = ethtool_op_get_link,
@@ -1815,6 +1849,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
18151849
.set_rxfh = mlx5e_set_rxfh,
18161850
.get_rxnfc = mlx5e_get_rxnfc,
18171851
.set_rxnfc = mlx5e_set_rxnfc,
1852+
.flash_device = mlx5e_flash_device,
18181853
.get_tunable = mlx5e_get_tunable,
18191854
.set_tunable = mlx5e_set_tunable,
18201855
.get_pauseparam = mlx5e_get_pauseparam,

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ void mlx5e_set_rq_type_params(struct mlx5_core_dev *mdev,
9696
params->log_rq_size = is_kdump_kernel() ?
9797
MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE :
9898
MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE;
99+
params->rq_headroom = params->xdp_prog ?
100+
XDP_PACKET_HEADROOM : MLX5_RX_HEADROOM;
101+
params->rq_headroom += NET_IP_ALIGN;
99102

100103
/* Extra room needed for build_skb */
101-
params->lro_wqe_sz -= MLX5_RX_HEADROOM +
104+
params->lro_wqe_sz -= params->rq_headroom +
102105
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
103106
}
104107

@@ -197,6 +200,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
197200
s->rx_buff_alloc_err += rq_stats->buff_alloc_err;
198201
s->rx_cqe_compress_blks += rq_stats->cqe_compress_blks;
199202
s->rx_cqe_compress_pkts += rq_stats->cqe_compress_pkts;
203+
s->rx_page_reuse += rq_stats->page_reuse;
200204
s->rx_cache_reuse += rq_stats->cache_reuse;
201205
s->rx_cache_full += rq_stats->cache_full;
202206
s->rx_cache_empty += rq_stats->cache_empty;
@@ -547,7 +551,6 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
547551
void *rqc = rqp->rqc;
548552
void *rqc_wq = MLX5_ADDR_OF(rqc, rqc, wq);
549553
u32 byte_count;
550-
u32 frag_sz;
551554
int npages;
552555
int wq_sz;
553556
int err;
@@ -579,13 +582,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
579582
goto err_rq_wq_destroy;
580583
}
581584

582-
if (rq->xdp_prog) {
583-
rq->buff.map_dir = DMA_BIDIRECTIONAL;
584-
rq->rx_headroom = XDP_PACKET_HEADROOM;
585-
} else {
586-
rq->buff.map_dir = DMA_FROM_DEVICE;
587-
rq->rx_headroom = MLX5_RX_HEADROOM;
588-
}
585+
rq->buff.map_dir = rq->xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;
586+
rq->rx_headroom = params->rq_headroom;
589587

590588
switch (rq->wq_type) {
591589
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
@@ -616,9 +614,10 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
616614
goto err_destroy_umr_mkey;
617615
break;
618616
default: /* MLX5_WQ_TYPE_LINKED_LIST */
619-
rq->dma_info = kzalloc_node(wq_sz * sizeof(*rq->dma_info),
620-
GFP_KERNEL, cpu_to_node(c->cpu));
621-
if (!rq->dma_info) {
617+
rq->wqe.frag_info =
618+
kzalloc_node(wq_sz * sizeof(*rq->wqe.frag_info),
619+
GFP_KERNEL, cpu_to_node(c->cpu));
620+
if (!rq->wqe.frag_info) {
622621
err = -ENOMEM;
623622
goto err_rq_wq_destroy;
624623
}
@@ -627,7 +626,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
627626

628627
rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe;
629628
if (!rq->handle_rx_cqe) {
630-
kfree(rq->dma_info);
629+
kfree(rq->wqe.frag_info);
631630
err = -EINVAL;
632631
netdev_err(c->netdev, "RX handler of RQ is not set, err %d\n", err);
633632
goto err_rq_wq_destroy;
@@ -636,15 +635,12 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
636635
rq->buff.wqe_sz = params->lro_en ?
637636
params->lro_wqe_sz :
638637
MLX5E_SW2HW_MTU(c->priv, c->netdev->mtu);
638+
rq->wqe.page_reuse = !params->xdp_prog && !params->lro_en;
639639
byte_count = rq->buff.wqe_sz;
640640

641641
/* calc the required page order */
642-
frag_sz = rq->rx_headroom +
643-
byte_count /* packet data */ +
644-
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
645-
frag_sz = SKB_DATA_ALIGN(frag_sz);
646-
647-
npages = DIV_ROUND_UP(frag_sz, PAGE_SIZE);
642+
rq->wqe.frag_sz = MLX5_SKB_FRAG_SZ(rq->rx_headroom + byte_count);
643+
npages = DIV_ROUND_UP(rq->wqe.frag_sz, PAGE_SIZE);
648644
rq->buff.page_order = order_base_2(npages);
649645

650646
byte_count |= MLX5_HW_START_PADDING;
@@ -689,7 +685,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)
689685
mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey);
690686
break;
691687
default: /* MLX5_WQ_TYPE_LINKED_LIST */
692-
kfree(rq->dma_info);
688+
kfree(rq->wqe.frag_info);
693689
}
694690

695691
for (i = rq->page_cache.head; i != rq->page_cache.tail;
@@ -871,6 +867,16 @@ static void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
871867
mlx5_wq_ll_pop(&rq->wq, wqe_ix_be,
872868
&wqe->next.next_wqe_index);
873869
}
870+
871+
if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST && rq->wqe.page_reuse) {
872+
/* Clean outstanding pages on handled WQEs that decided to do page-reuse,
873+
* but yet to be re-posted.
874+
*/
875+
int wq_sz = mlx5_wq_ll_get_size(&rq->wq);
876+
877+
for (wqe_ix = 0; wqe_ix < wq_sz; wqe_ix++)
878+
rq->dealloc_wqe(rq, wqe_ix);
879+
}
874880
}
875881

876882
static int mlx5e_open_rq(struct mlx5e_channel *c,

0 commit comments

Comments
 (0)