Commit aba6d497 authored by David S. Miller's avatar David S. Miller

Merge tag 'mlx5-updates-2020-03-29' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2020-03-29

1) mlx5 core level updates for mkey APIs + migrate some code to mlx5_ib

2) Use a separate work queue for fib event handling

3) Move new eswitch chains files to a new directory, to prepare for
upcoming E-Switch and offloads features.

4) Support indr block setup (TC_SETUP_FT) in Flow Table mode.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c13b5adb 07c264ab
...@@ -6392,6 +6392,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) ...@@ -6392,6 +6392,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
spin_lock_init(&dev->reset_flow_resource_lock); spin_lock_init(&dev->reset_flow_resource_lock);
xa_init(&dev->odp_mkeys); xa_init(&dev->odp_mkeys);
xa_init(&dev->sig_mrs); xa_init(&dev->sig_mrs);
spin_lock_init(&dev->mkey_lock);
spin_lock_init(&dev->dm.lock); spin_lock_init(&dev->dm.lock);
dev->dm.dev = mdev; dev->dm.dev = mdev;
......
...@@ -994,6 +994,11 @@ struct mlx5_ib_dev { ...@@ -994,6 +994,11 @@ struct mlx5_ib_dev {
/* sync used page count stats /* sync used page count stats
*/ */
struct mlx5_ib_resources devr; struct mlx5_ib_resources devr;
/* protect mkey key part */
spinlock_t mkey_lock;
u8 mkey_key;
struct mlx5_mr_cache cache; struct mlx5_mr_cache cache;
struct timer_list delay_timer; struct timer_list delay_timer;
/* Prevents soft lock on massive reg MRs */ /* Prevents soft lock on massive reg MRs */
......
...@@ -47,6 +47,46 @@ enum { ...@@ -47,6 +47,46 @@ enum {
#define MLX5_UMR_ALIGN 2048 #define MLX5_UMR_ALIGN 2048
static void
create_mkey_callback(int status, struct mlx5_async_work *context);
static void
assign_mkey_variant(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
u32 *in)
{
void *mkc;
u8 key;
spin_lock_irq(&dev->mkey_lock);
key = dev->mkey_key++;
spin_unlock_irq(&dev->mkey_lock);
mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
MLX5_SET(mkc, mkc, mkey_7_0, key);
mkey->key = key;
}
static int
mlx5_ib_create_mkey(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
u32 *in, int inlen)
{
assign_mkey_variant(dev, mkey, in);
return mlx5_core_create_mkey(dev->mdev, mkey, in, inlen);
}
static int
mlx5_ib_create_mkey_cb(struct mlx5_ib_dev *dev,
struct mlx5_core_mkey *mkey,
struct mlx5_async_ctx *async_ctx,
u32 *in, int inlen, u32 *out, int outlen,
struct mlx5_async_work *context)
{
MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
assign_mkey_variant(dev, mkey, in);
return mlx5_cmd_exec_cb(async_ctx, in, inlen, out, outlen,
create_mkey_callback, context);
}
static void clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr); static void clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr); static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
static int mr_cache_max_order(struct mlx5_ib_dev *dev); static int mr_cache_max_order(struct mlx5_ib_dev *dev);
...@@ -79,7 +119,7 @@ static bool use_umr_mtt_update(struct mlx5_ib_mr *mr, u64 start, u64 length) ...@@ -79,7 +119,7 @@ static bool use_umr_mtt_update(struct mlx5_ib_mr *mr, u64 start, u64 length)
length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1)); length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
} }
static void reg_mr_callback(int status, struct mlx5_async_work *context) static void create_mkey_callback(int status, struct mlx5_async_work *context)
{ {
struct mlx5_ib_mr *mr = struct mlx5_ib_mr *mr =
container_of(context, struct mlx5_ib_mr, cb_work); container_of(context, struct mlx5_ib_mr, cb_work);
...@@ -87,7 +127,6 @@ static void reg_mr_callback(int status, struct mlx5_async_work *context) ...@@ -87,7 +127,6 @@ static void reg_mr_callback(int status, struct mlx5_async_work *context)
struct mlx5_mr_cache *cache = &dev->cache; struct mlx5_mr_cache *cache = &dev->cache;
int c = order2idx(dev, mr->order); int c = order2idx(dev, mr->order);
struct mlx5_cache_ent *ent = &cache->ent[c]; struct mlx5_cache_ent *ent = &cache->ent[c];
u8 key;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ent->lock, flags); spin_lock_irqsave(&ent->lock, flags);
...@@ -102,10 +141,8 @@ static void reg_mr_callback(int status, struct mlx5_async_work *context) ...@@ -102,10 +141,8 @@ static void reg_mr_callback(int status, struct mlx5_async_work *context)
} }
mr->mmkey.type = MLX5_MKEY_MR; mr->mmkey.type = MLX5_MKEY_MR;
spin_lock_irqsave(&dev->mdev->priv.mkey_lock, flags); mr->mmkey.key |= mlx5_idx_to_mkey(
key = dev->mdev->priv.mkey_key++; MLX5_GET(create_mkey_out, mr->out, mkey_index));
spin_unlock_irqrestore(&dev->mdev->priv.mkey_lock, flags);
mr->mmkey.key = mlx5_idx_to_mkey(MLX5_GET(create_mkey_out, mr->out, mkey_index)) | key;
cache->last_add = jiffies; cache->last_add = jiffies;
...@@ -163,10 +200,10 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) ...@@ -163,10 +200,10 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
spin_lock_irq(&ent->lock); spin_lock_irq(&ent->lock);
ent->pending++; ent->pending++;
spin_unlock_irq(&ent->lock); spin_unlock_irq(&ent->lock);
err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey, err = mlx5_ib_create_mkey_cb(dev, &mr->mmkey,
&dev->async_ctx, in, inlen, &dev->async_ctx, in, inlen,
mr->out, sizeof(mr->out), mr->out, sizeof(mr->out),
reg_mr_callback, &mr->cb_work); &mr->cb_work);
if (err) { if (err) {
spin_lock_irq(&ent->lock); spin_lock_irq(&ent->lock);
ent->pending--; ent->pending--;
...@@ -685,7 +722,6 @@ struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc) ...@@ -685,7 +722,6 @@ struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc)
{ {
struct mlx5_ib_dev *dev = to_mdev(pd->device); struct mlx5_ib_dev *dev = to_mdev(pd->device);
int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
struct mlx5_core_dev *mdev = dev->mdev;
struct mlx5_ib_mr *mr; struct mlx5_ib_mr *mr;
void *mkc; void *mkc;
u32 *in; u32 *in;
...@@ -707,7 +743,7 @@ struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc) ...@@ -707,7 +743,7 @@ struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc)
MLX5_SET(mkc, mkc, length64, 1); MLX5_SET(mkc, mkc, length64, 1);
set_mkc_access_pd_addr_fields(mkc, acc, 0, pd); set_mkc_access_pd_addr_fields(mkc, acc, 0, pd);
err = mlx5_core_create_mkey(mdev, &mr->mmkey, in, inlen); err = mlx5_ib_create_mkey(dev, &mr->mmkey, in, inlen);
if (err) if (err)
goto err_in; goto err_in;
...@@ -1097,7 +1133,7 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd, ...@@ -1097,7 +1133,7 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,
get_octo_len(virt_addr, length, page_shift)); get_octo_len(virt_addr, length, page_shift));
} }
err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey, in, inlen); err = mlx5_ib_create_mkey(dev, &mr->mmkey, in, inlen);
if (err) { if (err) {
mlx5_ib_warn(dev, "create mkey failed\n"); mlx5_ib_warn(dev, "create mkey failed\n");
goto err_2; goto err_2;
...@@ -1137,7 +1173,6 @@ static struct ib_mr *mlx5_ib_get_dm_mr(struct ib_pd *pd, u64 start_addr, ...@@ -1137,7 +1173,6 @@ static struct ib_mr *mlx5_ib_get_dm_mr(struct ib_pd *pd, u64 start_addr,
{ {
struct mlx5_ib_dev *dev = to_mdev(pd->device); struct mlx5_ib_dev *dev = to_mdev(pd->device);
int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
struct mlx5_core_dev *mdev = dev->mdev;
struct mlx5_ib_mr *mr; struct mlx5_ib_mr *mr;
void *mkc; void *mkc;
u32 *in; u32 *in;
...@@ -1160,7 +1195,7 @@ static struct ib_mr *mlx5_ib_get_dm_mr(struct ib_pd *pd, u64 start_addr, ...@@ -1160,7 +1195,7 @@ static struct ib_mr *mlx5_ib_get_dm_mr(struct ib_pd *pd, u64 start_addr,
MLX5_SET64(mkc, mkc, len, length); MLX5_SET64(mkc, mkc, len, length);
set_mkc_access_pd_addr_fields(mkc, acc, start_addr, pd); set_mkc_access_pd_addr_fields(mkc, acc, start_addr, pd);
err = mlx5_core_create_mkey(mdev, &mr->mmkey, in, inlen); err = mlx5_ib_create_mkey(dev, &mr->mmkey, in, inlen);
if (err) if (err)
goto err_in; goto err_in;
...@@ -1638,7 +1673,7 @@ static int _mlx5_alloc_mkey_descs(struct ib_pd *pd, struct mlx5_ib_mr *mr, ...@@ -1638,7 +1673,7 @@ static int _mlx5_alloc_mkey_descs(struct ib_pd *pd, struct mlx5_ib_mr *mr,
mlx5_set_umr_free_mkey(pd, in, ndescs, access_mode, page_shift); mlx5_set_umr_free_mkey(pd, in, ndescs, access_mode, page_shift);
err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey, in, inlen); err = mlx5_ib_create_mkey(dev, &mr->mmkey, in, inlen);
if (err) if (err)
goto err_free_descs; goto err_free_descs;
...@@ -1905,7 +1940,7 @@ struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type, ...@@ -1905,7 +1940,7 @@ struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
MLX5_SET(mkc, mkc, en_rinval, !!((type == IB_MW_TYPE_2))); MLX5_SET(mkc, mkc, en_rinval, !!((type == IB_MW_TYPE_2)));
MLX5_SET(mkc, mkc, qpn, 0xffffff); MLX5_SET(mkc, mkc, qpn, 0xffffff);
err = mlx5_core_create_mkey(dev->mdev, &mw->mmkey, in, inlen); err = mlx5_ib_create_mkey(dev, &mw->mmkey, in, inlen);
if (err) if (err)
goto free; goto free;
......
...@@ -43,7 +43,7 @@ mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o ...@@ -43,7 +43,7 @@ mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o
# Core extra # Core extra
# #
mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o eswitch_offloads_termtbl.o \ mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o eswitch_offloads_termtbl.o \
ecpf.o rdma.o eswitch_offloads_chains.o ecpf.o rdma.o esw/chains.o
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
mlx5_core-$(CONFIG_VXLAN) += lib/vxlan.o mlx5_core-$(CONFIG_VXLAN) += lib/vxlan.o
mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
#include <net/netfilter/nf_flow_table.h> #include <net/netfilter/nf_flow_table.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "esw/chains.h"
#include "en/tc_ct.h" #include "en/tc_ct.h"
#include "en.h" #include "en.h"
#include "en_tc.h" #include "en_tc.h"
#include "en_rep.h" #include "en_rep.h"
#include "eswitch_offloads_chains.h"
#define MLX5_CT_ZONE_BITS (mlx5e_tc_attr_to_reg_mappings[ZONE_TO_REG].mlen * 8) #define MLX5_CT_ZONE_BITS (mlx5e_tc_attr_to_reg_mappings[ZONE_TO_REG].mlen * 8)
#define MLX5_CT_ZONE_MASK GENMASK(MLX5_CT_ZONE_BITS - 1, 0) #define MLX5_CT_ZONE_MASK GENMASK(MLX5_CT_ZONE_BITS - 1, 0)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <net/ipv6_stubs.h> #include <net/ipv6_stubs.h>
#include "eswitch.h" #include "eswitch.h"
#include "eswitch_offloads_chains.h" #include "esw/chains.h"
#include "en.h" #include "en.h"
#include "en_rep.h" #include "en_rep.h"
#include "en_tc.h" #include "en_tc.h"
...@@ -694,9 +694,9 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv) ...@@ -694,9 +694,9 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv)
static int static int
mlx5e_rep_indr_offload(struct net_device *netdev, mlx5e_rep_indr_offload(struct net_device *netdev,
struct flow_cls_offload *flower, struct flow_cls_offload *flower,
struct mlx5e_rep_indr_block_priv *indr_priv) struct mlx5e_rep_indr_block_priv *indr_priv,
unsigned long flags)
{ {
unsigned long flags = MLX5_TC_FLAG(EGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev); struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev);
int err = 0; int err = 0;
...@@ -717,20 +717,68 @@ mlx5e_rep_indr_offload(struct net_device *netdev, ...@@ -717,20 +717,68 @@ mlx5e_rep_indr_offload(struct net_device *netdev,
return err; return err;
} }
static int mlx5e_rep_indr_setup_block_cb(enum tc_setup_type type, static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
void *type_data, void *indr_priv) void *type_data, void *indr_priv)
{ {
unsigned long flags = MLX5_TC_FLAG(EGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
struct mlx5e_rep_indr_block_priv *priv = indr_priv; struct mlx5e_rep_indr_block_priv *priv = indr_priv;
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return mlx5e_rep_indr_offload(priv->netdev, type_data, priv); return mlx5e_rep_indr_offload(priv->netdev, type_data, priv,
flags);
default:
return -EOPNOTSUPP;
}
}
static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,
void *type_data, void *indr_priv)
{
struct mlx5e_rep_indr_block_priv *priv = indr_priv;
struct flow_cls_offload *f = type_data;
struct flow_cls_offload tmp;
struct mlx5e_priv *mpriv;
struct mlx5_eswitch *esw;
unsigned long flags;
int err;
mpriv = netdev_priv(priv->rpriv->netdev);
esw = mpriv->mdev->priv.eswitch;
flags = MLX5_TC_FLAG(EGRESS) |
MLX5_TC_FLAG(ESW_OFFLOAD) |
MLX5_TC_FLAG(FT_OFFLOAD);
switch (type) {
case TC_SETUP_CLSFLOWER:
memcpy(&tmp, f, sizeof(*f));
/* Re-use tc offload path by moving the ft flow to the
* reserved ft chain.
*
* FT offload can use prio range [0, INT_MAX], so we normalize
* it to range [1, mlx5_esw_chains_get_prio_range(esw)]
* as with tc, where prio 0 isn't supported.
*
* We only support chain 0 of FT offload.
*/
if (!mlx5_esw_chains_prios_supported(esw) ||
tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw) ||
tmp.common.chain_index)
return -EOPNOTSUPP;
tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw);
tmp.common.prio++;
err = mlx5e_rep_indr_offload(priv->netdev, &tmp, priv, flags);
memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
return err;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
} }
static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv) static void mlx5e_rep_indr_block_unbind(void *cb_priv)
{ {
struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv; struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
...@@ -741,9 +789,10 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv) ...@@ -741,9 +789,10 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
static LIST_HEAD(mlx5e_block_cb_list); static LIST_HEAD(mlx5e_block_cb_list);
static int static int
mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, mlx5e_rep_indr_setup_block(struct net_device *netdev,
struct mlx5e_rep_priv *rpriv, struct mlx5e_rep_priv *rpriv,
struct flow_block_offload *f) struct flow_block_offload *f,
flow_setup_cb_t *setup_cb)
{ {
struct mlx5e_rep_indr_block_priv *indr_priv; struct mlx5e_rep_indr_block_priv *indr_priv;
struct flow_block_cb *block_cb; struct flow_block_cb *block_cb;
...@@ -769,9 +818,8 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, ...@@ -769,9 +818,8 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
list_add(&indr_priv->list, list_add(&indr_priv->list,
&rpriv->uplink_priv.tc_indr_block_priv_list); &rpriv->uplink_priv.tc_indr_block_priv_list);
block_cb = flow_block_cb_alloc(mlx5e_rep_indr_setup_block_cb, block_cb = flow_block_cb_alloc(setup_cb, indr_priv, indr_priv,
indr_priv, indr_priv, mlx5e_rep_indr_block_unbind);
mlx5e_rep_indr_tc_block_unbind);
if (IS_ERR(block_cb)) { if (IS_ERR(block_cb)) {
list_del(&indr_priv->list); list_del(&indr_priv->list);
kfree(indr_priv); kfree(indr_priv);
...@@ -786,9 +834,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, ...@@ -786,9 +834,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
if (!indr_priv) if (!indr_priv)
return -ENOENT; return -ENOENT;
block_cb = flow_block_cb_lookup(f->block, block_cb = flow_block_cb_lookup(f->block, setup_cb, indr_priv);
mlx5e_rep_indr_setup_block_cb,
indr_priv);
if (!block_cb) if (!block_cb)
return -ENOENT; return -ENOENT;
...@@ -802,13 +848,16 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, ...@@ -802,13 +848,16 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
} }
static static
int mlx5e_rep_indr_setup_tc_cb(struct net_device *netdev, void *cb_priv, int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
enum tc_setup_type type, void *type_data) enum tc_setup_type type, void *type_data)
{ {
switch (type) { switch (type) {
case TC_SETUP_BLOCK: case TC_SETUP_BLOCK:
return mlx5e_rep_indr_setup_tc_block(netdev, cb_priv, return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
type_data); mlx5e_rep_indr_setup_tc_cb);
case TC_SETUP_FT:
return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
mlx5e_rep_indr_setup_ft_cb);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -820,7 +869,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv, ...@@ -820,7 +869,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
int err; int err;
err = __flow_indr_block_cb_register(netdev, rpriv, err = __flow_indr_block_cb_register(netdev, rpriv,
mlx5e_rep_indr_setup_tc_cb, mlx5e_rep_indr_setup_cb,
rpriv); rpriv);
if (err) { if (err) {
struct mlx5e_priv *priv = netdev_priv(rpriv->netdev); struct mlx5e_priv *priv = netdev_priv(rpriv->netdev);
...@@ -834,7 +883,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv, ...@@ -834,7 +883,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv, static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
struct net_device *netdev) struct net_device *netdev)
{ {
__flow_indr_block_cb_unregister(netdev, mlx5e_rep_indr_setup_tc_cb, __flow_indr_block_cb_unregister(netdev, mlx5e_rep_indr_setup_cb,
rpriv); rpriv);
} }
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include "en_rep.h" #include "en_rep.h"
#include "en_tc.h" #include "en_tc.h"
#include "eswitch.h" #include "eswitch.h"
#include "eswitch_offloads_chains.h" #include "esw/chains.h"
#include "fs_core.h" #include "fs_core.h"
#include "en/port.h" #include "en/port.h"
#include "en/tc_tun.h" #include "en/tc_tun.h"
......
# SPDX-License-Identifier: GPL-2.0-only
subdir-ccflags-y += -I$(src)/..
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <linux/mlx5/mlx5_ifc.h> #include <linux/mlx5/mlx5_ifc.h>
#include <linux/mlx5/fs.h> #include <linux/mlx5/fs.h>
#include "eswitch_offloads_chains.h" #include "esw/chains.h"
#include "en/mapping.h" #include "en/mapping.h"
#include "mlx5_core.h" #include "mlx5_core.h"
#include "fs_core.h" #include "fs_core.h"
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#ifndef __ML5_ESW_CHAINS_H__ #ifndef __ML5_ESW_CHAINS_H__
#define __ML5_ESW_CHAINS_H__ #define __ML5_ESW_CHAINS_H__
#include "eswitch.h"
bool bool
mlx5_esw_chains_prios_supported(struct mlx5_eswitch *esw); mlx5_esw_chains_prios_supported(struct mlx5_eswitch *esw);
bool bool
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <linux/mlx5/fs.h> #include <linux/mlx5/fs.h>
#include "mlx5_core.h" #include "mlx5_core.h"
#include "eswitch.h" #include "eswitch.h"
#include "eswitch_offloads_chains.h" #include "esw/chains.h"
#include "rdma.h" #include "rdma.h"
#include "en.h" #include "en.h"
#include "fs_core.h" #include "fs_core.h"
......
...@@ -93,9 +93,8 @@ static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev, ...@@ -93,9 +93,8 @@ static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev,
static void mlx5_lag_fib_event_flush(struct notifier_block *nb) static void mlx5_lag_fib_event_flush(struct notifier_block *nb)
{ {
struct lag_mp *mp = container_of(nb, struct lag_mp, fib_nb); struct lag_mp *mp = container_of(nb, struct lag_mp, fib_nb);
struct mlx5_lag *ldev = container_of(mp, struct mlx5_lag, lag_mp);
flush_workqueue(ldev->wq); flush_workqueue(mp->wq);
} }
struct mlx5_fib_event_work { struct mlx5_fib_event_work {
...@@ -293,7 +292,7 @@ static int mlx5_lag_fib_event(struct notifier_block *nb, ...@@ -293,7 +292,7 @@ static int mlx5_lag_fib_event(struct notifier_block *nb,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
queue_work(ldev->wq, &fib_work->work); queue_work(mp->wq, &fib_work->work);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -306,11 +305,17 @@ int mlx5_lag_mp_init(struct mlx5_lag *ldev) ...@@ -306,11 +305,17 @@ int mlx5_lag_mp_init(struct mlx5_lag *ldev)
if (mp->fib_nb.notifier_call) if (mp->fib_nb.notifier_call)
return 0; return 0;
mp->wq = create_singlethread_workqueue("mlx5_lag_mp");
if (!mp->wq)
return -ENOMEM;
mp->fib_nb.notifier_call = mlx5_lag_fib_event; mp->fib_nb.notifier_call = mlx5_lag_fib_event;
err = register_fib_notifier(&init_net, &mp->fib_nb, err = register_fib_notifier(&init_net, &mp->fib_nb,
mlx5_lag_fib_event_flush, NULL); mlx5_lag_fib_event_flush, NULL);
if (err) if (err) {
destroy_workqueue(mp->wq);
mp->fib_nb.notifier_call = NULL; mp->fib_nb.notifier_call = NULL;
}
return err; return err;
} }
...@@ -323,5 +328,6 @@ void mlx5_lag_mp_cleanup(struct mlx5_lag *ldev) ...@@ -323,5 +328,6 @@ void mlx5_lag_mp_cleanup(struct mlx5_lag *ldev)
return; return;
unregister_fib_notifier(&init_net, &mp->fib_nb); unregister_fib_notifier(&init_net, &mp->fib_nb);
destroy_workqueue(mp->wq);
mp->fib_nb.notifier_call = NULL; mp->fib_nb.notifier_call = NULL;
} }
...@@ -16,6 +16,7 @@ enum mlx5_lag_port_affinity { ...@@ -16,6 +16,7 @@ enum mlx5_lag_port_affinity {
struct lag_mp { struct lag_mp {
struct notifier_block fib_nb; struct notifier_block fib_nb;
struct fib_info *mfi; /* used in tracking fib events */ struct fib_info *mfi; /* used in tracking fib events */
struct workqueue_struct *wq;
}; };
#ifdef CONFIG_MLX5_ESWITCH #ifdef CONFIG_MLX5_ESWITCH
......
...@@ -1285,7 +1285,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) ...@@ -1285,7 +1285,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
mutex_init(&priv->alloc_mutex); mutex_init(&priv->alloc_mutex);
mutex_init(&priv->pgdir_mutex); mutex_init(&priv->pgdir_mutex);
INIT_LIST_HEAD(&priv->pgdir_list); INIT_LIST_HEAD(&priv->pgdir_list);
spin_lock_init(&priv->mkey_lock);
priv->dbg_root = debugfs_create_dir(dev_name(dev->device), priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
mlx5_debugfs_root); mlx5_debugfs_root);
......
...@@ -36,54 +36,31 @@ ...@@ -36,54 +36,31 @@
#include <linux/mlx5/cmd.h> #include <linux/mlx5/cmd.h>
#include "mlx5_core.h" #include "mlx5_core.h"
int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev, int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
struct mlx5_core_mkey *mkey, struct mlx5_core_mkey *mkey,
struct mlx5_async_ctx *async_ctx, u32 *in, u32 *in, int inlen)
int inlen, u32 *out, int outlen,
mlx5_async_cbk_t callback,
struct mlx5_async_work *context)
{ {
u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0};
u32 mkey_index; u32 mkey_index;
void *mkc; void *mkc;
int err; int err;
u8 key;
spin_lock_irq(&dev->priv.mkey_lock);
key = dev->priv.mkey_key++;
spin_unlock_irq(&dev->priv.mkey_lock);
mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY); MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
MLX5_SET(mkc, mkc, mkey_7_0, key);
if (callback)
return mlx5_cmd_exec_cb(async_ctx, in, inlen, out, outlen,
callback, context);
err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout)); err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout));
if (err) if (err)
return err; return err;
mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index); mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index);
mkey->iova = MLX5_GET64(mkc, mkc, start_addr); mkey->iova = MLX5_GET64(mkc, mkc, start_addr);
mkey->size = MLX5_GET64(mkc, mkc, len); mkey->size = MLX5_GET64(mkc, mkc, len);
mkey->key = mlx5_idx_to_mkey(mkey_index) | key; mkey->key |= mlx5_idx_to_mkey(mkey_index);
mkey->pd = MLX5_GET(mkc, mkc, pd); mkey->pd = MLX5_GET(mkc, mkc, pd);
mlx5_core_dbg(dev, "out 0x%x, key 0x%x, mkey 0x%x\n", mlx5_core_dbg(dev, "out 0x%x, mkey 0x%x\n", mkey_index, mkey->key);
mkey_index, key, mkey->key);
return 0; return 0;
} }
EXPORT_SYMBOL(mlx5_core_create_mkey_cb);
int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
struct mlx5_core_mkey *mkey,
u32 *in, int inlen)
{
return mlx5_core_create_mkey_cb(dev, mkey, NULL, in, inlen,
NULL, 0, NULL, NULL);
}
EXPORT_SYMBOL(mlx5_core_create_mkey); EXPORT_SYMBOL(mlx5_core_create_mkey);
int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
......
...@@ -575,10 +575,6 @@ struct mlx5_priv { ...@@ -575,10 +575,6 @@ struct mlx5_priv {
/* end: alloc staff */ /* end: alloc staff */
struct dentry *dbg_root; struct dentry *dbg_root;
/* protect mkey key part */
spinlock_t mkey_lock;
u8 mkey_key;
struct list_head dev_list; struct list_head dev_list;
struct list_head ctx_list; struct list_head ctx_list;
spinlock_t ctx_lock; spinlock_t ctx_lock;
...@@ -948,12 +944,6 @@ struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev, ...@@ -948,12 +944,6 @@ struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
gfp_t flags, int npages); gfp_t flags, int npages);
void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev, void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
struct mlx5_cmd_mailbox *head); struct mlx5_cmd_mailbox *head);
int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
struct mlx5_core_mkey *mkey,
struct mlx5_async_ctx *async_ctx, u32 *in,
int inlen, u32 *out, int outlen,
mlx5_async_cbk_t callback,
struct mlx5_async_work *context);
int mlx5_core_create_mkey(struct mlx5_core_dev *dev, int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
struct mlx5_core_mkey *mkey, struct mlx5_core_mkey *mkey,
u32 *in, int inlen); u32 *in, int inlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment