mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
Merge 009bd55dfc ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma") into android-mainline
Steps on the way to 5.11-rc1 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I14767e8fa20c1f9f27233e056b1b85f376f17655
This commit is contained in:
1
.mailmap
1
.mailmap
@@ -345,3 +345,4 @@ Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de>
|
||||
Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>
|
||||
Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
|
||||
Yusuke Goda <goda.yusuke@renesas.com>
|
||||
Zhu Yanjun <zyjzyj2000@gmail.com> <yanjunz@nvidia.com>
|
||||
|
||||
@@ -16412,7 +16412,7 @@ F: drivers/infiniband/sw/siw/
|
||||
F: include/uapi/rdma/siw-abi.h
|
||||
|
||||
SOFT-ROCE DRIVER (rxe)
|
||||
M: Zhu Yanjun <yanjunz@nvidia.com>
|
||||
M: Zhu Yanjun <zyjzyj2000@gmail.com>
|
||||
L: linux-rdma@vger.kernel.org
|
||||
S: Supported
|
||||
F: drivers/infiniband/sw/rxe/
|
||||
|
||||
@@ -1251,7 +1251,8 @@ out:
|
||||
EXPORT_SYMBOL(ib_cm_listen);
|
||||
|
||||
/**
|
||||
* Create a new listening ib_cm_id and listen on the given service ID.
|
||||
* ib_cm_insert_listen - Create a new listening ib_cm_id and listen on
|
||||
* the given service ID.
|
||||
*
|
||||
* If there's an existing ID listening on that same device and service ID,
|
||||
* return it.
|
||||
@@ -1765,7 +1766,7 @@ static u16 cm_get_bth_pkey(struct cm_work *work)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OPA SGID to IB SGID
|
||||
* cm_opa_to_ib_sgid - Convert OPA SGID to IB SGID
|
||||
* ULPs (such as IPoIB) do not understand OPA GIDs and will
|
||||
* reject them as the local_gid will not match the sgid. Therefore,
|
||||
* change the pathrec's SGID to an IB SGID.
|
||||
@@ -4273,8 +4274,8 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
|
||||
group = container_of(obj, struct cm_counter_group, obj);
|
||||
cm_attr = container_of(attr, struct cm_counter_attribute, attr);
|
||||
|
||||
return sprintf(buf, "%ld\n",
|
||||
atomic_long_read(&group->counter[cm_attr->index]));
|
||||
return sysfs_emit(buf, "%ld\n",
|
||||
atomic_long_read(&group->counter[cm_attr->index]));
|
||||
}
|
||||
|
||||
static const struct sysfs_ops cm_counter_ops = {
|
||||
|
||||
@@ -477,6 +477,10 @@ static void cma_release_dev(struct rdma_id_private *id_priv)
|
||||
list_del(&id_priv->list);
|
||||
cma_dev_put(id_priv->cma_dev);
|
||||
id_priv->cma_dev = NULL;
|
||||
if (id_priv->id.route.addr.dev_addr.sgid_attr) {
|
||||
rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
|
||||
id_priv->id.route.addr.dev_addr.sgid_attr = NULL;
|
||||
}
|
||||
mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
@@ -1861,9 +1865,6 @@ static void _destroy_id(struct rdma_id_private *id_priv,
|
||||
|
||||
kfree(id_priv->id.route.path_rec);
|
||||
|
||||
if (id_priv->id.route.addr.dev_addr.sgid_attr)
|
||||
rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
|
||||
|
||||
put_net(id_priv->id.route.addr.dev_addr.net);
|
||||
rdma_restrack_del(&id_priv->res);
|
||||
kfree(id_priv);
|
||||
@@ -2495,8 +2496,9 @@ static int cma_listen_handler(struct rdma_cm_id *id,
|
||||
return id_priv->id.event_handler(id, event);
|
||||
}
|
||||
|
||||
static void cma_listen_on_dev(struct rdma_id_private *id_priv,
|
||||
struct cma_device *cma_dev)
|
||||
static int cma_listen_on_dev(struct rdma_id_private *id_priv,
|
||||
struct cma_device *cma_dev,
|
||||
struct rdma_id_private **to_destroy)
|
||||
{
|
||||
struct rdma_id_private *dev_id_priv;
|
||||
struct net *net = id_priv->id.route.addr.dev_addr.net;
|
||||
@@ -2504,21 +2506,21 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
|
||||
|
||||
lockdep_assert_held(&lock);
|
||||
|
||||
*to_destroy = NULL;
|
||||
if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
dev_id_priv =
|
||||
__rdma_create_id(net, cma_listen_handler, id_priv,
|
||||
id_priv->id.ps, id_priv->id.qp_type, id_priv);
|
||||
if (IS_ERR(dev_id_priv))
|
||||
return;
|
||||
return PTR_ERR(dev_id_priv);
|
||||
|
||||
dev_id_priv->state = RDMA_CM_ADDR_BOUND;
|
||||
memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv),
|
||||
rdma_addr_size(cma_src_addr(id_priv)));
|
||||
|
||||
_cma_attach_to_dev(dev_id_priv, cma_dev);
|
||||
list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
|
||||
cma_id_get(id_priv);
|
||||
dev_id_priv->internal_id = 1;
|
||||
dev_id_priv->afonly = id_priv->afonly;
|
||||
@@ -2527,19 +2529,42 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
|
||||
|
||||
ret = rdma_listen(&dev_id_priv->id, id_priv->backlog);
|
||||
if (ret)
|
||||
dev_warn(&cma_dev->device->dev,
|
||||
"RDMA CMA: cma_listen_on_dev, error %d\n", ret);
|
||||
goto err_listen;
|
||||
list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
|
||||
return 0;
|
||||
err_listen:
|
||||
/* Caller must destroy this after releasing lock */
|
||||
*to_destroy = dev_id_priv;
|
||||
dev_warn(&cma_dev->device->dev, "RDMA CMA: %s, error %d\n", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cma_listen_on_all(struct rdma_id_private *id_priv)
|
||||
static int cma_listen_on_all(struct rdma_id_private *id_priv)
|
||||
{
|
||||
struct rdma_id_private *to_destroy;
|
||||
struct cma_device *cma_dev;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&lock);
|
||||
list_add_tail(&id_priv->list, &listen_any_list);
|
||||
list_for_each_entry(cma_dev, &dev_list, list)
|
||||
cma_listen_on_dev(id_priv, cma_dev);
|
||||
list_for_each_entry(cma_dev, &dev_list, list) {
|
||||
ret = cma_listen_on_dev(id_priv, cma_dev, &to_destroy);
|
||||
if (ret) {
|
||||
/* Prevent racing with cma_process_remove() */
|
||||
if (to_destroy)
|
||||
list_del_init(&to_destroy->list);
|
||||
goto err_listen;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&lock);
|
||||
return 0;
|
||||
|
||||
err_listen:
|
||||
list_del(&id_priv->list);
|
||||
mutex_unlock(&lock);
|
||||
if (to_destroy)
|
||||
rdma_destroy_id(&to_destroy->id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rdma_set_service_type(struct rdma_cm_id *id, int tos)
|
||||
@@ -3692,8 +3717,11 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
|
||||
ret = -ENOSYS;
|
||||
goto err;
|
||||
}
|
||||
} else
|
||||
cma_listen_on_all(id_priv);
|
||||
} else {
|
||||
ret = cma_listen_on_all(id_priv);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
@@ -4773,69 +4801,6 @@ static struct notifier_block cma_nb = {
|
||||
.notifier_call = cma_netdev_callback
|
||||
};
|
||||
|
||||
static int cma_add_one(struct ib_device *device)
|
||||
{
|
||||
struct cma_device *cma_dev;
|
||||
struct rdma_id_private *id_priv;
|
||||
unsigned int i;
|
||||
unsigned long supported_gids = 0;
|
||||
int ret;
|
||||
|
||||
cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL);
|
||||
if (!cma_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
cma_dev->device = device;
|
||||
cma_dev->default_gid_type = kcalloc(device->phys_port_cnt,
|
||||
sizeof(*cma_dev->default_gid_type),
|
||||
GFP_KERNEL);
|
||||
if (!cma_dev->default_gid_type) {
|
||||
ret = -ENOMEM;
|
||||
goto free_cma_dev;
|
||||
}
|
||||
|
||||
cma_dev->default_roce_tos = kcalloc(device->phys_port_cnt,
|
||||
sizeof(*cma_dev->default_roce_tos),
|
||||
GFP_KERNEL);
|
||||
if (!cma_dev->default_roce_tos) {
|
||||
ret = -ENOMEM;
|
||||
goto free_gid_type;
|
||||
}
|
||||
|
||||
rdma_for_each_port (device, i) {
|
||||
supported_gids = roce_gid_type_mask_support(device, i);
|
||||
WARN_ON(!supported_gids);
|
||||
if (supported_gids & (1 << CMA_PREFERRED_ROCE_GID_TYPE))
|
||||
cma_dev->default_gid_type[i - rdma_start_port(device)] =
|
||||
CMA_PREFERRED_ROCE_GID_TYPE;
|
||||
else
|
||||
cma_dev->default_gid_type[i - rdma_start_port(device)] =
|
||||
find_first_bit(&supported_gids, BITS_PER_LONG);
|
||||
cma_dev->default_roce_tos[i - rdma_start_port(device)] = 0;
|
||||
}
|
||||
|
||||
init_completion(&cma_dev->comp);
|
||||
refcount_set(&cma_dev->refcount, 1);
|
||||
INIT_LIST_HEAD(&cma_dev->id_list);
|
||||
ib_set_client_data(device, &cma_client, cma_dev);
|
||||
|
||||
mutex_lock(&lock);
|
||||
list_add_tail(&cma_dev->list, &dev_list);
|
||||
list_for_each_entry(id_priv, &listen_any_list, list)
|
||||
cma_listen_on_dev(id_priv, cma_dev);
|
||||
mutex_unlock(&lock);
|
||||
|
||||
trace_cm_add_one(device);
|
||||
return 0;
|
||||
|
||||
free_gid_type:
|
||||
kfree(cma_dev->default_gid_type);
|
||||
|
||||
free_cma_dev:
|
||||
kfree(cma_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cma_send_device_removal_put(struct rdma_id_private *id_priv)
|
||||
{
|
||||
struct rdma_cm_event event = { .event = RDMA_CM_EVENT_DEVICE_REMOVAL };
|
||||
@@ -4898,6 +4863,80 @@ static void cma_process_remove(struct cma_device *cma_dev)
|
||||
wait_for_completion(&cma_dev->comp);
|
||||
}
|
||||
|
||||
static int cma_add_one(struct ib_device *device)
|
||||
{
|
||||
struct rdma_id_private *to_destroy;
|
||||
struct cma_device *cma_dev;
|
||||
struct rdma_id_private *id_priv;
|
||||
unsigned int i;
|
||||
unsigned long supported_gids = 0;
|
||||
int ret;
|
||||
|
||||
cma_dev = kmalloc(sizeof(*cma_dev), GFP_KERNEL);
|
||||
if (!cma_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
cma_dev->device = device;
|
||||
cma_dev->default_gid_type = kcalloc(device->phys_port_cnt,
|
||||
sizeof(*cma_dev->default_gid_type),
|
||||
GFP_KERNEL);
|
||||
if (!cma_dev->default_gid_type) {
|
||||
ret = -ENOMEM;
|
||||
goto free_cma_dev;
|
||||
}
|
||||
|
||||
cma_dev->default_roce_tos = kcalloc(device->phys_port_cnt,
|
||||
sizeof(*cma_dev->default_roce_tos),
|
||||
GFP_KERNEL);
|
||||
if (!cma_dev->default_roce_tos) {
|
||||
ret = -ENOMEM;
|
||||
goto free_gid_type;
|
||||
}
|
||||
|
||||
rdma_for_each_port (device, i) {
|
||||
supported_gids = roce_gid_type_mask_support(device, i);
|
||||
WARN_ON(!supported_gids);
|
||||
if (supported_gids & (1 << CMA_PREFERRED_ROCE_GID_TYPE))
|
||||
cma_dev->default_gid_type[i - rdma_start_port(device)] =
|
||||
CMA_PREFERRED_ROCE_GID_TYPE;
|
||||
else
|
||||
cma_dev->default_gid_type[i - rdma_start_port(device)] =
|
||||
find_first_bit(&supported_gids, BITS_PER_LONG);
|
||||
cma_dev->default_roce_tos[i - rdma_start_port(device)] = 0;
|
||||
}
|
||||
|
||||
init_completion(&cma_dev->comp);
|
||||
refcount_set(&cma_dev->refcount, 1);
|
||||
INIT_LIST_HEAD(&cma_dev->id_list);
|
||||
ib_set_client_data(device, &cma_client, cma_dev);
|
||||
|
||||
mutex_lock(&lock);
|
||||
list_add_tail(&cma_dev->list, &dev_list);
|
||||
list_for_each_entry(id_priv, &listen_any_list, list) {
|
||||
ret = cma_listen_on_dev(id_priv, cma_dev, &to_destroy);
|
||||
if (ret)
|
||||
goto free_listen;
|
||||
}
|
||||
mutex_unlock(&lock);
|
||||
|
||||
trace_cm_add_one(device);
|
||||
return 0;
|
||||
|
||||
free_listen:
|
||||
list_del(&cma_dev->list);
|
||||
mutex_unlock(&lock);
|
||||
|
||||
/* cma_process_remove() will delete to_destroy */
|
||||
cma_process_remove(cma_dev);
|
||||
kfree(cma_dev->default_roce_tos);
|
||||
free_gid_type:
|
||||
kfree(cma_dev->default_gid_type);
|
||||
|
||||
free_cma_dev:
|
||||
kfree(cma_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cma_remove_one(struct ib_device *device, void *client_data)
|
||||
{
|
||||
struct cma_device *cma_dev = client_data;
|
||||
|
||||
@@ -115,7 +115,7 @@ static ssize_t default_roce_mode_show(struct config_item *item,
|
||||
if (gid_type < 0)
|
||||
return gid_type;
|
||||
|
||||
return sprintf(buf, "%s\n", ib_cache_gid_type_str(gid_type));
|
||||
return sysfs_emit(buf, "%s\n", ib_cache_gid_type_str(gid_type));
|
||||
}
|
||||
|
||||
static ssize_t default_roce_mode_store(struct config_item *item,
|
||||
@@ -157,7 +157,7 @@ static ssize_t default_roce_tos_show(struct config_item *item, char *buf)
|
||||
tos = cma_get_default_roce_tos(cma_dev, group->port_num);
|
||||
cma_configfs_params_put(cma_dev);
|
||||
|
||||
return sprintf(buf, "%u\n", tos);
|
||||
return sysfs_emit(buf, "%u\n", tos);
|
||||
}
|
||||
|
||||
static ssize_t default_roce_tos_store(struct config_item *item,
|
||||
|
||||
@@ -318,15 +318,12 @@ struct ib_device *ib_device_get_by_index(const struct net *net, u32 index);
|
||||
void nldev_init(void);
|
||||
void nldev_exit(void);
|
||||
|
||||
static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
|
||||
struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *attr,
|
||||
struct ib_udata *udata,
|
||||
struct ib_uqp_object *uobj)
|
||||
static inline struct ib_qp *
|
||||
_ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *attr, struct ib_udata *udata,
|
||||
struct ib_uqp_object *uobj, const char *caller)
|
||||
{
|
||||
enum ib_qp_type qp_type = attr->qp_type;
|
||||
struct ib_qp *qp;
|
||||
bool is_xrc;
|
||||
|
||||
if (!dev->ops.create_qp)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
@@ -347,6 +344,7 @@ static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
|
||||
qp->srq = attr->srq;
|
||||
qp->rwq_ind_tbl = attr->rwq_ind_tbl;
|
||||
qp->event_handler = attr->event_handler;
|
||||
qp->port = attr->port_num;
|
||||
|
||||
atomic_set(&qp->usecnt, 0);
|
||||
spin_lock_init(&qp->mr_lock);
|
||||
@@ -354,16 +352,9 @@ static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
|
||||
INIT_LIST_HEAD(&qp->sig_mrs);
|
||||
|
||||
rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP);
|
||||
/*
|
||||
* We don't track XRC QPs for now, because they don't have PD
|
||||
* and more importantly they are created internaly by driver,
|
||||
* see mlx5 create_dev_resources() as an example.
|
||||
*/
|
||||
is_xrc = qp_type == IB_QPT_XRC_INI || qp_type == IB_QPT_XRC_TGT;
|
||||
if ((qp_type < IB_QPT_MAX && !is_xrc) || qp_type == IB_QPT_DRIVER) {
|
||||
rdma_restrack_parent_name(&qp->res, &pd->res);
|
||||
rdma_restrack_add(&qp->res);
|
||||
}
|
||||
WARN_ONCE(!udata && !caller, "Missing kernel QP owner");
|
||||
rdma_restrack_set_name(&qp->res, udata ? NULL : caller);
|
||||
rdma_restrack_add(&qp->res);
|
||||
return qp;
|
||||
}
|
||||
|
||||
@@ -411,7 +402,6 @@ void rdma_umap_priv_init(struct rdma_umap_priv *priv,
|
||||
struct vm_area_struct *vma,
|
||||
struct rdma_user_mmap_entry *entry);
|
||||
|
||||
void ib_cq_pool_init(struct ib_device *dev);
|
||||
void ib_cq_pool_destroy(struct ib_device *dev);
|
||||
void ib_cq_pool_cleanup(struct ib_device *dev);
|
||||
|
||||
#endif /* _CORE_PRIV_H */
|
||||
|
||||
@@ -64,8 +64,40 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct rdma_counter *rdma_counter_alloc(struct ib_device *dev, u8 port,
|
||||
enum rdma_nl_counter_mode mode)
|
||||
static void auto_mode_init_counter(struct rdma_counter *counter,
|
||||
const struct ib_qp *qp,
|
||||
enum rdma_nl_counter_mask new_mask)
|
||||
{
|
||||
struct auto_mode_param *param = &counter->mode.param;
|
||||
|
||||
counter->mode.mode = RDMA_COUNTER_MODE_AUTO;
|
||||
counter->mode.mask = new_mask;
|
||||
|
||||
if (new_mask & RDMA_COUNTER_MASK_QP_TYPE)
|
||||
param->qp_type = qp->qp_type;
|
||||
}
|
||||
|
||||
static int __rdma_counter_bind_qp(struct rdma_counter *counter,
|
||||
struct ib_qp *qp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (qp->counter)
|
||||
return -EINVAL;
|
||||
|
||||
if (!qp->device->ops.counter_bind_qp)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
mutex_lock(&counter->lock);
|
||||
ret = qp->device->ops.counter_bind_qp(counter, qp);
|
||||
mutex_unlock(&counter->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u8 port,
|
||||
struct ib_qp *qp,
|
||||
enum rdma_nl_counter_mode mode)
|
||||
{
|
||||
struct rdma_port_counter *port_counter;
|
||||
struct rdma_counter *counter;
|
||||
@@ -88,11 +120,22 @@ static struct rdma_counter *rdma_counter_alloc(struct ib_device *dev, u8 port,
|
||||
|
||||
port_counter = &dev->port_data[port].port_counter;
|
||||
mutex_lock(&port_counter->lock);
|
||||
if (mode == RDMA_COUNTER_MODE_MANUAL) {
|
||||
switch (mode) {
|
||||
case RDMA_COUNTER_MODE_MANUAL:
|
||||
ret = __counter_set_mode(&port_counter->mode,
|
||||
RDMA_COUNTER_MODE_MANUAL, 0);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
mutex_unlock(&port_counter->lock);
|
||||
goto err_mode;
|
||||
}
|
||||
break;
|
||||
case RDMA_COUNTER_MODE_AUTO:
|
||||
auto_mode_init_counter(counter, qp, port_counter->mode.mask);
|
||||
break;
|
||||
default:
|
||||
ret = -EOPNOTSUPP;
|
||||
mutex_unlock(&port_counter->lock);
|
||||
goto err_mode;
|
||||
}
|
||||
|
||||
port_counter->num_counters++;
|
||||
@@ -102,10 +145,15 @@ static struct rdma_counter *rdma_counter_alloc(struct ib_device *dev, u8 port,
|
||||
kref_init(&counter->kref);
|
||||
mutex_init(&counter->lock);
|
||||
|
||||
ret = __rdma_counter_bind_qp(counter, qp);
|
||||
if (ret)
|
||||
goto err_mode;
|
||||
|
||||
rdma_restrack_parent_name(&counter->res, &qp->res);
|
||||
rdma_restrack_add(&counter->res);
|
||||
return counter;
|
||||
|
||||
err_mode:
|
||||
mutex_unlock(&port_counter->lock);
|
||||
kfree(counter->stats);
|
||||
err_stats:
|
||||
rdma_restrack_put(&counter->res);
|
||||
@@ -132,19 +180,6 @@ static void rdma_counter_free(struct rdma_counter *counter)
|
||||
kfree(counter);
|
||||
}
|
||||
|
||||
static void auto_mode_init_counter(struct rdma_counter *counter,
|
||||
const struct ib_qp *qp,
|
||||
enum rdma_nl_counter_mask new_mask)
|
||||
{
|
||||
struct auto_mode_param *param = &counter->mode.param;
|
||||
|
||||
counter->mode.mode = RDMA_COUNTER_MODE_AUTO;
|
||||
counter->mode.mask = new_mask;
|
||||
|
||||
if (new_mask & RDMA_COUNTER_MASK_QP_TYPE)
|
||||
param->qp_type = qp->qp_type;
|
||||
}
|
||||
|
||||
static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter,
|
||||
enum rdma_nl_counter_mask auto_mask)
|
||||
{
|
||||
@@ -161,24 +196,6 @@ static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter,
|
||||
return match;
|
||||
}
|
||||
|
||||
static int __rdma_counter_bind_qp(struct rdma_counter *counter,
|
||||
struct ib_qp *qp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (qp->counter)
|
||||
return -EINVAL;
|
||||
|
||||
if (!qp->device->ops.counter_bind_qp)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
mutex_lock(&counter->lock);
|
||||
ret = qp->device->ops.counter_bind_qp(counter, qp);
|
||||
mutex_unlock(&counter->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __rdma_counter_unbind_qp(struct ib_qp *qp)
|
||||
{
|
||||
struct rdma_counter *counter = qp->counter;
|
||||
@@ -247,13 +264,6 @@ next:
|
||||
return counter;
|
||||
}
|
||||
|
||||
static void rdma_counter_res_add(struct rdma_counter *counter,
|
||||
struct ib_qp *qp)
|
||||
{
|
||||
rdma_restrack_parent_name(&counter->res, &qp->res);
|
||||
rdma_restrack_add(&counter->res);
|
||||
}
|
||||
|
||||
static void counter_release(struct kref *kref)
|
||||
{
|
||||
struct rdma_counter *counter;
|
||||
@@ -275,7 +285,7 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u8 port)
|
||||
struct rdma_counter *counter;
|
||||
int ret;
|
||||
|
||||
if (!qp->res.valid || rdma_is_kernel_res(&qp->res))
|
||||
if (!rdma_restrack_is_tracked(&qp->res) || rdma_is_kernel_res(&qp->res))
|
||||
return 0;
|
||||
|
||||
if (!rdma_is_port_valid(dev, port))
|
||||
@@ -293,19 +303,9 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u8 port)
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
counter = rdma_counter_alloc(dev, port, RDMA_COUNTER_MODE_AUTO);
|
||||
counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_AUTO);
|
||||
if (!counter)
|
||||
return -ENOMEM;
|
||||
|
||||
auto_mode_init_counter(counter, qp, port_counter->mode.mask);
|
||||
|
||||
ret = __rdma_counter_bind_qp(counter, qp);
|
||||
if (ret) {
|
||||
rdma_counter_free(counter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdma_counter_res_add(counter, qp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -419,15 +419,6 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int rdma_counter_bind_qp_manual(struct rdma_counter *counter,
|
||||
struct ib_qp *qp)
|
||||
{
|
||||
if ((counter->device != qp->device) || (counter->port != qp->port))
|
||||
return -EINVAL;
|
||||
|
||||
return __rdma_counter_bind_qp(counter, qp);
|
||||
}
|
||||
|
||||
static struct rdma_counter *rdma_get_counter_by_id(struct ib_device *dev,
|
||||
u32 counter_id)
|
||||
{
|
||||
@@ -475,7 +466,12 @@ int rdma_counter_bind_qpn(struct ib_device *dev, u8 port,
|
||||
goto err_task;
|
||||
}
|
||||
|
||||
ret = rdma_counter_bind_qp_manual(counter, qp);
|
||||
if ((counter->device != qp->device) || (counter->port != qp->port)) {
|
||||
ret = -EINVAL;
|
||||
goto err_task;
|
||||
}
|
||||
|
||||
ret = __rdma_counter_bind_qp(counter, qp);
|
||||
if (ret)
|
||||
goto err_task;
|
||||
|
||||
@@ -520,26 +516,18 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port,
|
||||
goto err;
|
||||
}
|
||||
|
||||
counter = rdma_counter_alloc(dev, port, RDMA_COUNTER_MODE_MANUAL);
|
||||
counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_MANUAL);
|
||||
if (!counter) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = rdma_counter_bind_qp_manual(counter, qp);
|
||||
if (ret)
|
||||
goto err_bind;
|
||||
|
||||
if (counter_id)
|
||||
*counter_id = counter->id;
|
||||
|
||||
rdma_counter_res_add(counter, qp);
|
||||
|
||||
rdma_restrack_put(&qp->res);
|
||||
return ret;
|
||||
return 0;
|
||||
|
||||
err_bind:
|
||||
rdma_counter_free(counter);
|
||||
err:
|
||||
rdma_restrack_put(&qp->res);
|
||||
return ret;
|
||||
|
||||
@@ -123,7 +123,7 @@ static int __ib_process_cq(struct ib_cq *cq, int budget, struct ib_wc *wcs,
|
||||
}
|
||||
|
||||
/**
|
||||
* ib_process_direct_cq - process a CQ in caller context
|
||||
* ib_process_cq_direct - process a CQ in caller context
|
||||
* @cq: CQ to process
|
||||
* @budget: number of CQEs to poll for
|
||||
*
|
||||
@@ -197,7 +197,7 @@ static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
|
||||
}
|
||||
|
||||
/**
|
||||
* __ib_alloc_cq allocate a completion queue
|
||||
* __ib_alloc_cq - allocate a completion queue
|
||||
* @dev: device to allocate the CQ for
|
||||
* @private: driver private data, accessible from cq->cq_context
|
||||
* @nr_cqe: number of CQEs to allocate
|
||||
@@ -349,16 +349,7 @@ void ib_free_cq(struct ib_cq *cq)
|
||||
}
|
||||
EXPORT_SYMBOL(ib_free_cq);
|
||||
|
||||
void ib_cq_pool_init(struct ib_device *dev)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
spin_lock_init(&dev->cq_pools_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(dev->cq_pools); i++)
|
||||
INIT_LIST_HEAD(&dev->cq_pools[i]);
|
||||
}
|
||||
|
||||
void ib_cq_pool_destroy(struct ib_device *dev)
|
||||
void ib_cq_pool_cleanup(struct ib_device *dev)
|
||||
{
|
||||
struct ib_cq *cq, *n;
|
||||
unsigned int i;
|
||||
@@ -367,6 +358,7 @@ void ib_cq_pool_destroy(struct ib_device *dev)
|
||||
list_for_each_entry_safe(cq, n, &dev->cq_pools[i],
|
||||
pool_entry) {
|
||||
WARN_ON(cq->cqe_used);
|
||||
list_del(&cq->pool_entry);
|
||||
cq->shared = false;
|
||||
ib_free_cq(cq);
|
||||
}
|
||||
|
||||
@@ -284,6 +284,7 @@ static void ib_device_check_mandatory(struct ib_device *device)
|
||||
IB_MANDATORY_FUNC(poll_cq),
|
||||
IB_MANDATORY_FUNC(req_notify_cq),
|
||||
IB_MANDATORY_FUNC(get_dma_mr),
|
||||
IB_MANDATORY_FUNC(reg_user_mr),
|
||||
IB_MANDATORY_FUNC(dereg_mr),
|
||||
IB_MANDATORY_FUNC(get_port_immutable)
|
||||
};
|
||||
@@ -569,6 +570,7 @@ static void rdma_init_coredev(struct ib_core_device *coredev,
|
||||
struct ib_device *_ib_alloc_device(size_t size)
|
||||
{
|
||||
struct ib_device *device;
|
||||
unsigned int i;
|
||||
|
||||
if (WARN_ON(size < sizeof(struct ib_device)))
|
||||
return NULL;
|
||||
@@ -600,6 +602,41 @@ struct ib_device *_ib_alloc_device(size_t size)
|
||||
init_completion(&device->unreg_completion);
|
||||
INIT_WORK(&device->unregistration_work, ib_unregister_work);
|
||||
|
||||
spin_lock_init(&device->cq_pools_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(device->cq_pools); i++)
|
||||
INIT_LIST_HEAD(&device->cq_pools[i]);
|
||||
|
||||
device->uverbs_cmd_mask =
|
||||
BIT_ULL(IB_USER_VERBS_CMD_ALLOC_MW) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_ATTACH_MCAST) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CLOSE_XRCD) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_AH) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_CREATE_XSRQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DEALLOC_MW) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DESTROY_AH) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DESTROY_SRQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_DETACH_MCAST) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_OPEN_QP) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_OPEN_XRCD) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_REG_MR) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_REREG_MR) |
|
||||
BIT_ULL(IB_USER_VERBS_CMD_RESIZE_CQ);
|
||||
return device;
|
||||
}
|
||||
EXPORT_SYMBOL(_ib_alloc_device);
|
||||
@@ -1177,25 +1214,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void setup_dma_device(struct ib_device *device,
|
||||
struct device *dma_device)
|
||||
{
|
||||
/*
|
||||
* If the caller does not provide a DMA capable device then the IB
|
||||
* device will be used. In this case the caller should fully setup the
|
||||
* ibdev for DMA. This usually means using dma_virt_ops.
|
||||
*/
|
||||
#ifdef CONFIG_DMA_VIRT_OPS
|
||||
if (!dma_device) {
|
||||
device->dev.dma_ops = &dma_virt_ops;
|
||||
dma_device = &device->dev;
|
||||
}
|
||||
#endif
|
||||
WARN_ON(!dma_device);
|
||||
device->dma_device = dma_device;
|
||||
WARN_ON(!device->dma_device->dma_parms);
|
||||
}
|
||||
|
||||
/*
|
||||
* setup_device() allocates memory and sets up data that requires calling the
|
||||
* device ops, this is the only reason these actions are not done during
|
||||
@@ -1249,7 +1267,7 @@ static void disable_device(struct ib_device *device)
|
||||
remove_client_context(device, cid);
|
||||
}
|
||||
|
||||
ib_cq_pool_destroy(device);
|
||||
ib_cq_pool_cleanup(device);
|
||||
|
||||
/* Pairs with refcount_set in enable_device */
|
||||
ib_device_put(device);
|
||||
@@ -1294,8 +1312,6 @@ static int enable_device_and_get(struct ib_device *device)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ib_cq_pool_init(device);
|
||||
|
||||
down_read(&clients_rwsem);
|
||||
xa_for_each_marked (&clients, index, client, CLIENT_REGISTERED) {
|
||||
ret = add_client_context(device, client);
|
||||
@@ -1341,7 +1357,14 @@ int ib_register_device(struct ib_device *device, const char *name,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
setup_dma_device(device, dma_device);
|
||||
/*
|
||||
* If the caller does not provide a DMA capable device then the IB core
|
||||
* will set up ib_sge and scatterlist structures that stash the kernel
|
||||
* virtual address into the address field.
|
||||
*/
|
||||
WARN_ON(dma_device && !dma_device->dma_parms);
|
||||
device->dma_device = dma_device;
|
||||
|
||||
ret = setup_device(device);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1374,9 +1397,6 @@ int ib_register_device(struct ib_device *device, const char *name,
|
||||
}
|
||||
|
||||
ret = enable_device_and_get(device);
|
||||
dev_set_uevent_suppress(&device->dev, false);
|
||||
/* Mark for userspace that device is ready */
|
||||
kobject_uevent(&device->dev.kobj, KOBJ_ADD);
|
||||
if (ret) {
|
||||
void (*dealloc_fn)(struct ib_device *);
|
||||
|
||||
@@ -1396,8 +1416,12 @@ int ib_register_device(struct ib_device *device, const char *name,
|
||||
ib_device_put(device);
|
||||
__ib_unregister_device(device);
|
||||
device->ops.dealloc_driver = dealloc_fn;
|
||||
dev_set_uevent_suppress(&device->dev, false);
|
||||
return ret;
|
||||
}
|
||||
dev_set_uevent_suppress(&device->dev, false);
|
||||
/* Mark for userspace that device is ready */
|
||||
kobject_uevent(&device->dev.kobj, KOBJ_ADD);
|
||||
ib_device_put(device);
|
||||
|
||||
return 0;
|
||||
@@ -2576,6 +2600,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
SET_DEVICE_OP(dev_ops, create_qp);
|
||||
SET_DEVICE_OP(dev_ops, create_rwq_ind_table);
|
||||
SET_DEVICE_OP(dev_ops, create_srq);
|
||||
SET_DEVICE_OP(dev_ops, create_user_ah);
|
||||
SET_DEVICE_OP(dev_ops, create_wq);
|
||||
SET_DEVICE_OP(dev_ops, dealloc_dm);
|
||||
SET_DEVICE_OP(dev_ops, dealloc_driver);
|
||||
@@ -2675,6 +2700,21 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
}
|
||||
EXPORT_SYMBOL(ib_set_device_ops);
|
||||
|
||||
#ifdef CONFIG_INFINIBAND_VIRT_DMA
|
||||
int ib_dma_virt_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents)
|
||||
{
|
||||
struct scatterlist *s;
|
||||
int i;
|
||||
|
||||
for_each_sg(sg, s, nents, i) {
|
||||
sg_dma_address(s) = (uintptr_t)sg_virt(s);
|
||||
sg_dma_len(s) = s->length;
|
||||
}
|
||||
return nents;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_dma_virt_map_sg);
|
||||
#endif /* CONFIG_INFINIBAND_VIRT_DMA */
|
||||
|
||||
static const struct rdma_nl_cbs ibnl_ls_cb_table[RDMA_NL_LS_NUM_OPS] = {
|
||||
[RDMA_NL_LS_OP_RESOLVE] = {
|
||||
.doit = ib_nl_handle_resolve_resp,
|
||||
|
||||
@@ -141,7 +141,7 @@ int iwpm_wait_complete_req(struct iwpm_nlmsg_request *nlmsg_request);
|
||||
int iwpm_get_nlmsg_seq(void);
|
||||
|
||||
/**
|
||||
* iwpm_add_reminfo - Add remote address info of the connecting peer
|
||||
* iwpm_add_remote_info - Add remote address info of the connecting peer
|
||||
* to the remote info hash table
|
||||
* @reminfo: The remote info to be added
|
||||
*/
|
||||
|
||||
@@ -137,15 +137,9 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj,
|
||||
} else if (uobj->object) {
|
||||
ret = uobj->uapi_object->type_class->destroy_hw(uobj, reason,
|
||||
attrs);
|
||||
if (ret) {
|
||||
if (ib_is_destroy_retryable(ret, reason, uobj))
|
||||
return ret;
|
||||
|
||||
/* Nothing to be done, dangle the memory and move on */
|
||||
WARN(true,
|
||||
"ib_uverbs: failed to remove uobject id %d, driver err=%d",
|
||||
uobj->id, ret);
|
||||
}
|
||||
if (ret)
|
||||
/* Nothing to be done, wait till ucontext will clean it */
|
||||
return ret;
|
||||
|
||||
uobj->object = NULL;
|
||||
}
|
||||
@@ -543,12 +537,7 @@ static int __must_check destroy_hw_idr_uobject(struct ib_uobject *uobj,
|
||||
struct uverbs_obj_idr_type, type);
|
||||
int ret = idr_type->destroy_object(uobj, why, attrs);
|
||||
|
||||
/*
|
||||
* We can only fail gracefully if the user requested to destroy the
|
||||
* object or when a retry may be called upon an error.
|
||||
* In the rest of the cases, just remove whatever you can.
|
||||
*/
|
||||
if (ib_is_destroy_retryable(ret, why, uobj))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (why == RDMA_REMOVE_ABORT)
|
||||
@@ -581,11 +570,8 @@ static int __must_check destroy_hw_fd_uobject(struct ib_uobject *uobj,
|
||||
{
|
||||
const struct uverbs_obj_fd_type *fd_type = container_of(
|
||||
uobj->uapi_object->type_attrs, struct uverbs_obj_fd_type, type);
|
||||
int ret = fd_type->destroy_object(uobj, why);
|
||||
|
||||
if (ib_is_destroy_retryable(ret, why, uobj))
|
||||
return ret;
|
||||
|
||||
fd_type->destroy_object(uobj, why);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -609,6 +595,27 @@ static void alloc_commit_idr_uobject(struct ib_uobject *uobj)
|
||||
WARN_ON(old != NULL);
|
||||
}
|
||||
|
||||
static void swap_idr_uobjects(struct ib_uobject *obj_old,
|
||||
struct ib_uobject *obj_new)
|
||||
{
|
||||
struct ib_uverbs_file *ufile = obj_old->ufile;
|
||||
void *old;
|
||||
|
||||
/*
|
||||
* New must be an object that been allocated but not yet committed, this
|
||||
* moves the pre-committed state to obj_old, new still must be comitted.
|
||||
*/
|
||||
old = xa_cmpxchg(&ufile->idr, obj_old->id, obj_old, XA_ZERO_ENTRY,
|
||||
GFP_KERNEL);
|
||||
if (WARN_ON(old != obj_old))
|
||||
return;
|
||||
|
||||
swap(obj_old->id, obj_new->id);
|
||||
|
||||
old = xa_cmpxchg(&ufile->idr, obj_old->id, NULL, obj_old, GFP_KERNEL);
|
||||
WARN_ON(old != NULL);
|
||||
}
|
||||
|
||||
static void alloc_commit_fd_uobject(struct ib_uobject *uobj)
|
||||
{
|
||||
int fd = uobj->id;
|
||||
@@ -654,6 +661,35 @@ void rdma_alloc_commit_uobject(struct ib_uobject *uobj,
|
||||
up_read(&ufile->hw_destroy_rwsem);
|
||||
}
|
||||
|
||||
/*
|
||||
* new_uobj will be assigned to the handle currently used by to_uobj, and
|
||||
* to_uobj will be destroyed.
|
||||
*
|
||||
* Upon return the caller must do:
|
||||
* rdma_alloc_commit_uobject(new_uobj)
|
||||
* uobj_put_destroy(to_uobj)
|
||||
*
|
||||
* to_uobj must have a write get but the put mode switches to destroy once
|
||||
* this is called.
|
||||
*/
|
||||
void rdma_assign_uobject(struct ib_uobject *to_uobj, struct ib_uobject *new_uobj,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
assert_uverbs_usecnt(new_uobj, UVERBS_LOOKUP_WRITE);
|
||||
|
||||
if (WARN_ON(to_uobj->uapi_object != new_uobj->uapi_object ||
|
||||
!to_uobj->uapi_object->type_class->swap_uobjects))
|
||||
return;
|
||||
|
||||
to_uobj->uapi_object->type_class->swap_uobjects(to_uobj, new_uobj);
|
||||
|
||||
/*
|
||||
* If this fails then the uobject is still completely valid (though with
|
||||
* a new ID) and we leak it until context close.
|
||||
*/
|
||||
uverbs_destroy_uobject(to_uobj, RDMA_REMOVE_DESTROY, attrs);
|
||||
}
|
||||
|
||||
/*
|
||||
* This consumes the kref for uobj. It is up to the caller to unwind the HW
|
||||
* object and anything else connected to uobj before calling this.
|
||||
@@ -761,6 +797,7 @@ const struct uverbs_obj_type_class uverbs_idr_class = {
|
||||
.lookup_put = lookup_put_idr_uobject,
|
||||
.destroy_hw = destroy_hw_idr_uobject,
|
||||
.remove_handle = remove_handle_idr_uobject,
|
||||
.swap_uobjects = swap_idr_uobjects,
|
||||
};
|
||||
EXPORT_SYMBOL(uverbs_idr_class);
|
||||
|
||||
@@ -863,11 +900,18 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
|
||||
* racing with a lookup_get.
|
||||
*/
|
||||
WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE));
|
||||
if (reason == RDMA_REMOVE_DRIVER_FAILURE)
|
||||
obj->object = NULL;
|
||||
if (!uverbs_destroy_uobject(obj, reason, &attrs))
|
||||
ret = 0;
|
||||
else
|
||||
atomic_set(&obj->usecnt, 0);
|
||||
}
|
||||
|
||||
if (reason == RDMA_REMOVE_DRIVER_FAILURE) {
|
||||
WARN_ON(!list_empty(&ufile->uobjects));
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -889,21 +933,12 @@ void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
|
||||
if (!ufile->ucontext)
|
||||
goto done;
|
||||
|
||||
ufile->ucontext->cleanup_retryable = true;
|
||||
while (!list_empty(&ufile->uobjects))
|
||||
if (__uverbs_cleanup_ufile(ufile, reason)) {
|
||||
/*
|
||||
* No entry was cleaned-up successfully during this
|
||||
* iteration. It is a driver bug to fail destruction.
|
||||
*/
|
||||
WARN_ON(!list_empty(&ufile->uobjects));
|
||||
break;
|
||||
}
|
||||
|
||||
ufile->ucontext->cleanup_retryable = false;
|
||||
if (!list_empty(&ufile->uobjects))
|
||||
__uverbs_cleanup_ufile(ufile, reason);
|
||||
while (!list_empty(&ufile->uobjects) &&
|
||||
!__uverbs_cleanup_ufile(ufile, reason)) {
|
||||
}
|
||||
|
||||
if (WARN_ON(!list_empty(&ufile->uobjects)))
|
||||
__uverbs_cleanup_ufile(ufile, RDMA_REMOVE_DRIVER_FAILURE);
|
||||
ufile_destroy_ucontext(ufile, reason);
|
||||
|
||||
done:
|
||||
|
||||
@@ -221,19 +221,29 @@ void rdma_restrack_add(struct rdma_restrack_entry *res)
|
||||
{
|
||||
struct ib_device *dev = res_to_dev(res);
|
||||
struct rdma_restrack_root *rt;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
if (res->no_track)
|
||||
goto out;
|
||||
|
||||
rt = &dev->res[res->type];
|
||||
|
||||
if (res->type == RDMA_RESTRACK_QP) {
|
||||
/* Special case to ensure that LQPN points to right QP */
|
||||
struct ib_qp *qp = container_of(res, struct ib_qp, res);
|
||||
|
||||
ret = xa_insert(&rt->xa, qp->qp_num, res, GFP_KERNEL);
|
||||
res->id = ret ? 0 : qp->qp_num;
|
||||
WARN_ONCE(qp->qp_num >> 24 || qp->port >> 8,
|
||||
"QP number 0x%0X and port 0x%0X", qp->qp_num,
|
||||
qp->port);
|
||||
res->id = qp->qp_num;
|
||||
if (qp->qp_type == IB_QPT_SMI || qp->qp_type == IB_QPT_GSI)
|
||||
res->id |= qp->port << 24;
|
||||
ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL);
|
||||
if (ret)
|
||||
res->id = 0;
|
||||
} else if (res->type == RDMA_RESTRACK_COUNTER) {
|
||||
/* Special case to ensure that cntn points to right counter */
|
||||
struct rdma_counter *counter;
|
||||
@@ -246,6 +256,7 @@ void rdma_restrack_add(struct rdma_restrack_entry *res)
|
||||
&rt->next_id, GFP_KERNEL);
|
||||
}
|
||||
|
||||
out:
|
||||
if (!ret)
|
||||
res->valid = true;
|
||||
}
|
||||
@@ -318,6 +329,9 @@ void rdma_restrack_del(struct rdma_restrack_entry *res)
|
||||
return;
|
||||
}
|
||||
|
||||
if (res->no_track)
|
||||
goto out;
|
||||
|
||||
dev = res_to_dev(res);
|
||||
if (WARN_ON(!dev))
|
||||
return;
|
||||
@@ -328,8 +342,9 @@ void rdma_restrack_del(struct rdma_restrack_entry *res)
|
||||
if (res->type == RDMA_RESTRACK_MR || res->type == RDMA_RESTRACK_QP)
|
||||
return;
|
||||
WARN_ON(old != res);
|
||||
res->valid = false;
|
||||
|
||||
out:
|
||||
res->valid = false;
|
||||
rdma_restrack_put(res);
|
||||
wait_for_completion(&res->comp);
|
||||
}
|
||||
|
||||
@@ -285,8 +285,11 @@ static void rdma_rw_unmap_sg(struct ib_device *dev, struct scatterlist *sg,
|
||||
static int rdma_rw_map_sg(struct ib_device *dev, struct scatterlist *sg,
|
||||
u32 sg_cnt, enum dma_data_direction dir)
|
||||
{
|
||||
if (is_pci_p2pdma_page(sg_page(sg)))
|
||||
if (is_pci_p2pdma_page(sg_page(sg))) {
|
||||
if (WARN_ON_ONCE(ib_uses_virt_dma(dev)))
|
||||
return 0;
|
||||
return pci_p2pdma_map_sg(dev->dma_device, sg, sg_cnt, dir);
|
||||
}
|
||||
return ib_dma_map_sg(dev, sg, sg_cnt, dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -1435,7 +1435,8 @@ enum opa_pr_supported {
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if current PR query can be an OPA query.
|
||||
* opa_pr_query_possible - Check if current PR query can be an OPA query.
|
||||
*
|
||||
* Retuns PR_NOT_SUPPORTED if a path record query is not
|
||||
* possible, PR_OPA_SUPPORTED if an OPA path record query
|
||||
* is possible and PR_IB_SUPPORTED if an IB path record
|
||||
|
||||
@@ -165,9 +165,11 @@ static ssize_t state_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%d: %s\n", attr.state,
|
||||
attr.state >= 0 && attr.state < ARRAY_SIZE(state_name) ?
|
||||
state_name[attr.state] : "UNKNOWN");
|
||||
return sysfs_emit(buf, "%d: %s\n", attr.state,
|
||||
attr.state >= 0 &&
|
||||
attr.state < ARRAY_SIZE(state_name) ?
|
||||
state_name[attr.state] :
|
||||
"UNKNOWN");
|
||||
}
|
||||
|
||||
static ssize_t lid_show(struct ib_port *p, struct port_attribute *unused,
|
||||
@@ -180,7 +182,7 @@ static ssize_t lid_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "0x%x\n", attr.lid);
|
||||
return sysfs_emit(buf, "0x%x\n", attr.lid);
|
||||
}
|
||||
|
||||
static ssize_t lid_mask_count_show(struct ib_port *p,
|
||||
@@ -194,7 +196,7 @@ static ssize_t lid_mask_count_show(struct ib_port *p,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%d\n", attr.lmc);
|
||||
return sysfs_emit(buf, "%d\n", attr.lmc);
|
||||
}
|
||||
|
||||
static ssize_t sm_lid_show(struct ib_port *p, struct port_attribute *unused,
|
||||
@@ -207,7 +209,7 @@ static ssize_t sm_lid_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "0x%x\n", attr.sm_lid);
|
||||
return sysfs_emit(buf, "0x%x\n", attr.sm_lid);
|
||||
}
|
||||
|
||||
static ssize_t sm_sl_show(struct ib_port *p, struct port_attribute *unused,
|
||||
@@ -220,7 +222,7 @@ static ssize_t sm_sl_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%d\n", attr.sm_sl);
|
||||
return sysfs_emit(buf, "%d\n", attr.sm_sl);
|
||||
}
|
||||
|
||||
static ssize_t cap_mask_show(struct ib_port *p, struct port_attribute *unused,
|
||||
@@ -233,7 +235,7 @@ static ssize_t cap_mask_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "0x%08x\n", attr.port_cap_flags);
|
||||
return sysfs_emit(buf, "0x%08x\n", attr.port_cap_flags);
|
||||
}
|
||||
|
||||
static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
|
||||
@@ -273,6 +275,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
|
||||
speed = " HDR";
|
||||
rate = 500;
|
||||
break;
|
||||
case IB_SPEED_NDR:
|
||||
speed = " NDR";
|
||||
rate = 1000;
|
||||
break;
|
||||
case IB_SPEED_SDR:
|
||||
default: /* default to SDR for invalid rates */
|
||||
speed = " SDR";
|
||||
@@ -284,9 +290,9 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (rate < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
|
||||
rate / 10, rate % 10 ? ".5" : "",
|
||||
ib_width_enum_to_int(attr.active_width), speed);
|
||||
return sysfs_emit(buf, "%d%s Gb/sec (%dX%s)\n", rate / 10,
|
||||
rate % 10 ? ".5" : "",
|
||||
ib_width_enum_to_int(attr.active_width), speed);
|
||||
}
|
||||
|
||||
static const char *phys_state_to_str(enum ib_port_phys_state phys_state)
|
||||
@@ -318,21 +324,28 @@ static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%d: %s\n", attr.phys_state,
|
||||
phys_state_to_str(attr.phys_state));
|
||||
return sysfs_emit(buf, "%d: %s\n", attr.phys_state,
|
||||
phys_state_to_str(attr.phys_state));
|
||||
}
|
||||
|
||||
static ssize_t link_layer_show(struct ib_port *p, struct port_attribute *unused,
|
||||
char *buf)
|
||||
{
|
||||
const char *output;
|
||||
|
||||
switch (rdma_port_get_link_layer(p->ibdev, p->port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
return sprintf(buf, "%s\n", "InfiniBand");
|
||||
output = "InfiniBand";
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
return sprintf(buf, "%s\n", "Ethernet");
|
||||
output = "Ethernet";
|
||||
break;
|
||||
default:
|
||||
return sprintf(buf, "%s\n", "Unknown");
|
||||
output = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
return sysfs_emit(buf, "%s\n", output);
|
||||
}
|
||||
|
||||
static PORT_ATTR_RO(state);
|
||||
@@ -358,27 +371,28 @@ static struct attribute *port_default_attrs[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static size_t print_ndev(const struct ib_gid_attr *gid_attr, char *buf)
|
||||
static ssize_t print_ndev(const struct ib_gid_attr *gid_attr, char *buf)
|
||||
{
|
||||
struct net_device *ndev;
|
||||
size_t ret = -EINVAL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
rcu_read_lock();
|
||||
ndev = rcu_dereference(gid_attr->ndev);
|
||||
if (ndev)
|
||||
ret = sprintf(buf, "%s\n", ndev->name);
|
||||
ret = sysfs_emit(buf, "%s\n", ndev->name);
|
||||
rcu_read_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t print_gid_type(const struct ib_gid_attr *gid_attr, char *buf)
|
||||
static ssize_t print_gid_type(const struct ib_gid_attr *gid_attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%s\n", ib_cache_gid_type_str(gid_attr->gid_type));
|
||||
return sysfs_emit(buf, "%s\n",
|
||||
ib_cache_gid_type_str(gid_attr->gid_type));
|
||||
}
|
||||
|
||||
static ssize_t _show_port_gid_attr(
|
||||
struct ib_port *p, struct port_attribute *attr, char *buf,
|
||||
size_t (*print)(const struct ib_gid_attr *gid_attr, char *buf))
|
||||
ssize_t (*print)(const struct ib_gid_attr *gid_attr, char *buf))
|
||||
{
|
||||
struct port_table_attribute *tab_attr =
|
||||
container_of(attr, struct port_table_attribute, attr);
|
||||
@@ -401,7 +415,7 @@ static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
|
||||
struct port_table_attribute *tab_attr =
|
||||
container_of(attr, struct port_table_attribute, attr);
|
||||
const struct ib_gid_attr *gid_attr;
|
||||
ssize_t ret;
|
||||
int len;
|
||||
|
||||
gid_attr = rdma_get_gid_attr(p->ibdev, p->port_num, tab_attr->index);
|
||||
if (IS_ERR(gid_attr)) {
|
||||
@@ -416,12 +430,12 @@ static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
|
||||
* space throwing such error on fail to read gid, return zero
|
||||
* GID as before. This maintains backward compatibility.
|
||||
*/
|
||||
return sprintf(buf, "%pI6\n", zgid.raw);
|
||||
return sysfs_emit(buf, "%pI6\n", zgid.raw);
|
||||
}
|
||||
|
||||
ret = sprintf(buf, "%pI6\n", gid_attr->gid.raw);
|
||||
len = sysfs_emit(buf, "%pI6\n", gid_attr->gid.raw);
|
||||
rdma_put_gid_attr(gid_attr);
|
||||
return ret;
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t show_port_gid_attr_ndev(struct ib_port *p,
|
||||
@@ -443,13 +457,13 @@ static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
|
||||
struct port_table_attribute *tab_attr =
|
||||
container_of(attr, struct port_table_attribute, attr);
|
||||
u16 pkey;
|
||||
ssize_t ret;
|
||||
int ret;
|
||||
|
||||
ret = ib_query_pkey(p->ibdev, p->port_num, tab_attr->index, &pkey);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "0x%04x\n", pkey);
|
||||
return sysfs_emit(buf, "0x%04x\n", pkey);
|
||||
}
|
||||
|
||||
#define PORT_PMA_ATTR(_name, _counter, _width, _offset) \
|
||||
@@ -521,8 +535,9 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
|
||||
container_of(attr, struct port_table_attribute, attr);
|
||||
int offset = tab_attr->index & 0xffff;
|
||||
int width = (tab_attr->index >> 16) & 0xff;
|
||||
ssize_t ret;
|
||||
int ret;
|
||||
u8 data[8];
|
||||
int len;
|
||||
|
||||
ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data,
|
||||
40 + offset / 8, sizeof(data));
|
||||
@@ -531,30 +546,27 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
|
||||
|
||||
switch (width) {
|
||||
case 4:
|
||||
ret = sprintf(buf, "%u\n", (*data >>
|
||||
(4 - (offset % 8))) & 0xf);
|
||||
len = sysfs_emit(buf, "%u\n",
|
||||
(*data >> (4 - (offset % 8))) & 0xf);
|
||||
break;
|
||||
case 8:
|
||||
ret = sprintf(buf, "%u\n", *data);
|
||||
len = sysfs_emit(buf, "%u\n", *data);
|
||||
break;
|
||||
case 16:
|
||||
ret = sprintf(buf, "%u\n",
|
||||
be16_to_cpup((__be16 *)data));
|
||||
len = sysfs_emit(buf, "%u\n", be16_to_cpup((__be16 *)data));
|
||||
break;
|
||||
case 32:
|
||||
ret = sprintf(buf, "%u\n",
|
||||
be32_to_cpup((__be32 *)data));
|
||||
len = sysfs_emit(buf, "%u\n", be32_to_cpup((__be32 *)data));
|
||||
break;
|
||||
case 64:
|
||||
ret = sprintf(buf, "%llu\n",
|
||||
be64_to_cpup((__be64 *)data));
|
||||
len = sysfs_emit(buf, "%llu\n", be64_to_cpup((__be64 *)data));
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = 0;
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return len;
|
||||
}
|
||||
|
||||
static PORT_PMA_ATTR(symbol_error , 0, 16, 32);
|
||||
@@ -815,12 +827,12 @@ static int update_hw_stats(struct ib_device *dev, struct rdma_hw_stats *stats,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t print_hw_stat(struct ib_device *dev, int port_num,
|
||||
struct rdma_hw_stats *stats, int index, char *buf)
|
||||
static int print_hw_stat(struct ib_device *dev, int port_num,
|
||||
struct rdma_hw_stats *stats, int index, char *buf)
|
||||
{
|
||||
u64 v = rdma_counter_get_hwstat_value(dev, port_num, index);
|
||||
|
||||
return sprintf(buf, "%llu\n", stats->value[index] + v);
|
||||
return sysfs_emit(buf, "%llu\n", stats->value[index] + v);
|
||||
}
|
||||
|
||||
static ssize_t show_hw_stats(struct kobject *kobj, struct attribute *attr,
|
||||
@@ -877,7 +889,7 @@ static ssize_t show_stats_lifespan(struct kobject *kobj,
|
||||
msecs = jiffies_to_msecs(stats->lifespan);
|
||||
mutex_unlock(&stats->lock);
|
||||
|
||||
return sprintf(buf, "%d\n", msecs);
|
||||
return sysfs_emit(buf, "%d\n", msecs);
|
||||
}
|
||||
|
||||
static ssize_t set_stats_lifespan(struct kobject *kobj,
|
||||
@@ -1224,21 +1236,34 @@ err_put:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char *node_type_string(int node_type)
|
||||
{
|
||||
switch (node_type) {
|
||||
case RDMA_NODE_IB_CA:
|
||||
return "CA";
|
||||
case RDMA_NODE_IB_SWITCH:
|
||||
return "switch";
|
||||
case RDMA_NODE_IB_ROUTER:
|
||||
return "router";
|
||||
case RDMA_NODE_RNIC:
|
||||
return "RNIC";
|
||||
case RDMA_NODE_USNIC:
|
||||
return "usNIC";
|
||||
case RDMA_NODE_USNIC_UDP:
|
||||
return "usNIC UDP";
|
||||
case RDMA_NODE_UNSPECIFIED:
|
||||
return "unspecified";
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
static ssize_t node_type_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
switch (dev->node_type) {
|
||||
case RDMA_NODE_IB_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
|
||||
case RDMA_NODE_RNIC: return sprintf(buf, "%d: RNIC\n", dev->node_type);
|
||||
case RDMA_NODE_USNIC: return sprintf(buf, "%d: usNIC\n", dev->node_type);
|
||||
case RDMA_NODE_USNIC_UDP: return sprintf(buf, "%d: usNIC UDP\n", dev->node_type);
|
||||
case RDMA_NODE_UNSPECIFIED: return sprintf(buf, "%d: unspecified\n", dev->node_type);
|
||||
case RDMA_NODE_IB_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
|
||||
case RDMA_NODE_IB_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type);
|
||||
default: return sprintf(buf, "%d: <unknown>\n", dev->node_type);
|
||||
}
|
||||
return sysfs_emit(buf, "%d: %s\n", dev->node_type,
|
||||
node_type_string(dev->node_type));
|
||||
}
|
||||
static DEVICE_ATTR_RO(node_type);
|
||||
|
||||
@@ -1246,12 +1271,13 @@ static ssize_t sys_image_guid_show(struct device *device,
|
||||
struct device_attribute *dev_attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
__be16 *guid = (__be16 *)&dev->attrs.sys_image_guid;
|
||||
|
||||
return sprintf(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[0]),
|
||||
be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[1]),
|
||||
be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[2]),
|
||||
be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[3]));
|
||||
return sysfs_emit(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(guid[0]),
|
||||
be16_to_cpu(guid[1]),
|
||||
be16_to_cpu(guid[2]),
|
||||
be16_to_cpu(guid[3]));
|
||||
}
|
||||
static DEVICE_ATTR_RO(sys_image_guid);
|
||||
|
||||
@@ -1259,12 +1285,13 @@ static ssize_t node_guid_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
__be16 *node_guid = (__be16 *)&dev->node_guid;
|
||||
|
||||
return sprintf(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(((__be16 *) &dev->node_guid)[0]),
|
||||
be16_to_cpu(((__be16 *) &dev->node_guid)[1]),
|
||||
be16_to_cpu(((__be16 *) &dev->node_guid)[2]),
|
||||
be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
|
||||
return sysfs_emit(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(node_guid[0]),
|
||||
be16_to_cpu(node_guid[1]),
|
||||
be16_to_cpu(node_guid[2]),
|
||||
be16_to_cpu(node_guid[3]));
|
||||
}
|
||||
static DEVICE_ATTR_RO(node_guid);
|
||||
|
||||
@@ -1273,7 +1300,7 @@ static ssize_t node_desc_show(struct device *device,
|
||||
{
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
return sprintf(buf, "%.64s\n", dev->node_desc);
|
||||
return sysfs_emit(buf, "%.64s\n", dev->node_desc);
|
||||
}
|
||||
|
||||
static ssize_t node_desc_store(struct device *device,
|
||||
@@ -1300,10 +1327,11 @@ static ssize_t fw_ver_show(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
char version[IB_FW_VERSION_NAME_MAX] = {};
|
||||
|
||||
ib_get_device_fw_str(dev, buf);
|
||||
strlcat(buf, "\n", IB_FW_VERSION_NAME_MAX);
|
||||
return strlen(buf);
|
||||
ib_get_device_fw_str(dev, version);
|
||||
|
||||
return sysfs_emit(buf, "%s\n", version);
|
||||
}
|
||||
static DEVICE_ATTR_RO(fw_ver);
|
||||
|
||||
|
||||
@@ -1825,7 +1825,7 @@ static ssize_t show_abi_version(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", RDMA_USER_CM_ABI_VERSION);
|
||||
return sysfs_emit(buf, "%d\n", RDMA_USER_CM_ABI_VERSION);
|
||||
}
|
||||
static DEVICE_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
|
||||
|
||||
|
||||
@@ -84,6 +84,15 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
||||
dma_addr_t mask;
|
||||
int i;
|
||||
|
||||
if (umem->is_odp) {
|
||||
unsigned int page_size = BIT(to_ib_umem_odp(umem)->page_shift);
|
||||
|
||||
/* ODP must always be self consistent. */
|
||||
if (!(pgsz_bitmap & page_size))
|
||||
return 0;
|
||||
return page_size;
|
||||
}
|
||||
|
||||
/* rdma_for_each_block() has a bug if the page size is smaller than the
|
||||
* page size used to build the umem. For now prevent smaller page sizes
|
||||
* from being returned.
|
||||
@@ -220,10 +229,10 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
||||
|
||||
cur_base += ret * PAGE_SIZE;
|
||||
npages -= ret;
|
||||
sg = __sg_alloc_table_from_pages(
|
||||
&umem->sg_head, page_list, ret, 0, ret << PAGE_SHIFT,
|
||||
dma_get_max_seg_size(device->dma_device), sg, npages,
|
||||
GFP_KERNEL);
|
||||
sg = __sg_alloc_table_from_pages(&umem->sg_head, page_list, ret,
|
||||
0, ret << PAGE_SHIFT,
|
||||
ib_dma_max_seg_size(device), sg, npages,
|
||||
GFP_KERNEL);
|
||||
umem->sg_nents = umem->sg_head.nents;
|
||||
if (IS_ERR(sg)) {
|
||||
unpin_user_pages_dirty_lock(page_list, ret, 0);
|
||||
|
||||
@@ -1191,7 +1191,7 @@ static ssize_t ibdev_show(struct device *dev, struct device_attribute *attr,
|
||||
if (!port)
|
||||
return -ENODEV;
|
||||
|
||||
return sprintf(buf, "%s\n", dev_name(&port->ib_dev->dev));
|
||||
return sysfs_emit(buf, "%s\n", dev_name(&port->ib_dev->dev));
|
||||
}
|
||||
static DEVICE_ATTR_RO(ibdev);
|
||||
|
||||
@@ -1203,7 +1203,7 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr,
|
||||
if (!port)
|
||||
return -ENODEV;
|
||||
|
||||
return sprintf(buf, "%d\n", port->port_num);
|
||||
return sysfs_emit(buf, "%d\n", port->port_num);
|
||||
}
|
||||
static DEVICE_ATTR_RO(port);
|
||||
|
||||
@@ -1222,7 +1222,7 @@ static char *umad_devnode(struct device *dev, umode_t *mode)
|
||||
static ssize_t abi_version_show(struct class *class,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
|
||||
return sysfs_emit(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
|
||||
}
|
||||
static CLASS_ATTR_RO(abi_version);
|
||||
|
||||
|
||||
@@ -681,8 +681,7 @@ int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
|
||||
return 0;
|
||||
|
||||
ret = ib_dealloc_xrcd_user(xrcd, &attrs->driver_udata);
|
||||
|
||||
if (ib_is_destroy_retryable(ret, why, uobject)) {
|
||||
if (ret) {
|
||||
atomic_inc(&xrcd->usecnt);
|
||||
return ret;
|
||||
}
|
||||
@@ -690,7 +689,7 @@ int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
|
||||
if (inode)
|
||||
xrcd_table_delete(dev, inode);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
|
||||
@@ -710,29 +709,20 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
|
||||
if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
|
||||
return -EINVAL;
|
||||
|
||||
ret = ib_check_mr_access(cmd.access_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_MR, attrs, &ib_dev);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
ret = ib_check_mr_access(ib_dev, cmd.access_flags);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
if (cmd.access_flags & IB_ACCESS_ON_DEMAND) {
|
||||
if (!(pd->device->attrs.device_cap_flags &
|
||||
IB_DEVICE_ON_DEMAND_PAGING)) {
|
||||
pr_debug("ODP support not available\n");
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
}
|
||||
}
|
||||
|
||||
mr = pd->device->ops.reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
|
||||
cmd.access_flags,
|
||||
&attrs->driver_udata);
|
||||
@@ -774,23 +764,28 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct ib_uverbs_rereg_mr cmd;
|
||||
struct ib_uverbs_rereg_mr_resp resp;
|
||||
struct ib_pd *pd = NULL;
|
||||
struct ib_mr *mr;
|
||||
struct ib_pd *old_pd;
|
||||
int ret;
|
||||
struct ib_uobject *uobj;
|
||||
struct ib_uobject *new_uobj;
|
||||
struct ib_device *ib_dev;
|
||||
struct ib_pd *orig_pd;
|
||||
struct ib_pd *new_pd;
|
||||
struct ib_mr *new_mr;
|
||||
|
||||
ret = uverbs_request(attrs, &cmd, sizeof(cmd));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (cmd.flags & ~IB_MR_REREG_SUPPORTED || !cmd.flags)
|
||||
if (!cmd.flags)
|
||||
return -EINVAL;
|
||||
|
||||
if (cmd.flags & ~IB_MR_REREG_SUPPORTED)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if ((cmd.flags & IB_MR_REREG_TRANS) &&
|
||||
(!cmd.start || !cmd.hca_va || 0 >= cmd.length ||
|
||||
(cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)))
|
||||
return -EINVAL;
|
||||
(cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
|
||||
return -EINVAL;
|
||||
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, attrs);
|
||||
if (IS_ERR(uobj))
|
||||
@@ -804,36 +799,74 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs)
|
||||
}
|
||||
|
||||
if (cmd.flags & IB_MR_REREG_ACCESS) {
|
||||
ret = ib_check_mr_access(cmd.access_flags);
|
||||
ret = ib_check_mr_access(mr->device, cmd.access_flags);
|
||||
if (ret)
|
||||
goto put_uobjs;
|
||||
}
|
||||
|
||||
orig_pd = mr->pd;
|
||||
if (cmd.flags & IB_MR_REREG_PD) {
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle,
|
||||
attrs);
|
||||
if (!pd) {
|
||||
new_pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle,
|
||||
attrs);
|
||||
if (!new_pd) {
|
||||
ret = -EINVAL;
|
||||
goto put_uobjs;
|
||||
}
|
||||
} else {
|
||||
new_pd = mr->pd;
|
||||
}
|
||||
|
||||
old_pd = mr->pd;
|
||||
ret = mr->device->ops.rereg_user_mr(mr, cmd.flags, cmd.start,
|
||||
cmd.length, cmd.hca_va,
|
||||
cmd.access_flags, pd,
|
||||
&attrs->driver_udata);
|
||||
if (ret)
|
||||
/*
|
||||
* The driver might create a new HW object as part of the rereg, we need
|
||||
* to have a uobject ready to hold it.
|
||||
*/
|
||||
new_uobj = uobj_alloc(UVERBS_OBJECT_MR, attrs, &ib_dev);
|
||||
if (IS_ERR(new_uobj)) {
|
||||
ret = PTR_ERR(new_uobj);
|
||||
goto put_uobj_pd;
|
||||
|
||||
if (cmd.flags & IB_MR_REREG_PD) {
|
||||
atomic_inc(&pd->usecnt);
|
||||
mr->pd = pd;
|
||||
atomic_dec(&old_pd->usecnt);
|
||||
}
|
||||
|
||||
if (cmd.flags & IB_MR_REREG_TRANS)
|
||||
mr->iova = cmd.hca_va;
|
||||
new_mr = ib_dev->ops.rereg_user_mr(mr, cmd.flags, cmd.start, cmd.length,
|
||||
cmd.hca_va, cmd.access_flags, new_pd,
|
||||
&attrs->driver_udata);
|
||||
if (IS_ERR(new_mr)) {
|
||||
ret = PTR_ERR(new_mr);
|
||||
goto put_new_uobj;
|
||||
}
|
||||
if (new_mr) {
|
||||
new_mr->device = new_pd->device;
|
||||
new_mr->pd = new_pd;
|
||||
new_mr->type = IB_MR_TYPE_USER;
|
||||
new_mr->dm = NULL;
|
||||
new_mr->sig_attrs = NULL;
|
||||
new_mr->uobject = uobj;
|
||||
atomic_inc(&new_pd->usecnt);
|
||||
new_mr->iova = cmd.hca_va;
|
||||
new_uobj->object = new_mr;
|
||||
|
||||
rdma_restrack_new(&new_mr->res, RDMA_RESTRACK_MR);
|
||||
rdma_restrack_set_name(&new_mr->res, NULL);
|
||||
rdma_restrack_add(&new_mr->res);
|
||||
|
||||
/*
|
||||
* The new uobj for the new HW object is put into the same spot
|
||||
* in the IDR and the old uobj & HW object is deleted.
|
||||
*/
|
||||
rdma_assign_uobject(uobj, new_uobj, attrs);
|
||||
rdma_alloc_commit_uobject(new_uobj, attrs);
|
||||
uobj_put_destroy(uobj);
|
||||
new_uobj = NULL;
|
||||
uobj = NULL;
|
||||
mr = new_mr;
|
||||
} else {
|
||||
if (cmd.flags & IB_MR_REREG_PD) {
|
||||
atomic_dec(&orig_pd->usecnt);
|
||||
mr->pd = new_pd;
|
||||
atomic_inc(&new_pd->usecnt);
|
||||
}
|
||||
if (cmd.flags & IB_MR_REREG_TRANS)
|
||||
mr->iova = cmd.hca_va;
|
||||
}
|
||||
|
||||
memset(&resp, 0, sizeof(resp));
|
||||
resp.lkey = mr->lkey;
|
||||
@@ -841,12 +874,16 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs)
|
||||
|
||||
ret = uverbs_response(attrs, &resp, sizeof(resp));
|
||||
|
||||
put_new_uobj:
|
||||
if (new_uobj)
|
||||
uobj_alloc_abort(new_uobj, attrs);
|
||||
put_uobj_pd:
|
||||
if (cmd.flags & IB_MR_REREG_PD)
|
||||
uobj_put_obj_read(pd);
|
||||
uobj_put_obj_read(new_pd);
|
||||
|
||||
put_uobjs:
|
||||
uobj_put_write(uobj);
|
||||
if (uobj)
|
||||
uobj_put_write(uobj);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1401,8 +1438,8 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
|
||||
if (cmd->qp_type == IB_QPT_XRC_TGT)
|
||||
qp = ib_create_qp(pd, &attr);
|
||||
else
|
||||
qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata,
|
||||
obj);
|
||||
qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata, obj,
|
||||
NULL);
|
||||
|
||||
if (IS_ERR(qp)) {
|
||||
ret = PTR_ERR(qp);
|
||||
@@ -1906,8 +1943,7 @@ static int ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (cmd.base.attr_mask &
|
||||
~((IB_USER_LEGACY_LAST_QP_ATTR_MASK << 1) - 1))
|
||||
if (cmd.base.attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return modify_qp(attrs, &cmd);
|
||||
@@ -1929,10 +1965,7 @@ static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs)
|
||||
* Last bit is reserved for extending the attr_mask by
|
||||
* using another field.
|
||||
*/
|
||||
BUILD_BUG_ON(IB_USER_LAST_QP_ATTR_MASK == (1ULL << 31));
|
||||
|
||||
if (cmd.base.attr_mask &
|
||||
~((IB_USER_LAST_QP_ATTR_MASK << 1) - 1))
|
||||
if (cmd.base.attr_mask & ~(IB_QP_ATTR_STANDARD_BITS | IB_QP_RATE_LIMIT))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = modify_qp(attrs, &cmd);
|
||||
@@ -3693,13 +3726,13 @@ const struct uapi_definition uverbs_def_write_intf[] = {
|
||||
ib_uverbs_create_ah,
|
||||
UAPI_DEF_WRITE_UDATA_IO(
|
||||
struct ib_uverbs_create_ah,
|
||||
struct ib_uverbs_create_ah_resp),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(create_ah)),
|
||||
struct ib_uverbs_create_ah_resp)),
|
||||
DECLARE_UVERBS_WRITE(
|
||||
IB_USER_VERBS_CMD_DESTROY_AH,
|
||||
ib_uverbs_destroy_ah,
|
||||
UAPI_DEF_WRITE_I(struct ib_uverbs_destroy_ah),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(destroy_ah))),
|
||||
UAPI_DEF_WRITE_I(struct ib_uverbs_destroy_ah)),
|
||||
UAPI_DEF_OBJ_NEEDS_FN(create_user_ah),
|
||||
UAPI_DEF_OBJ_NEEDS_FN(destroy_ah)),
|
||||
|
||||
DECLARE_UVERBS_OBJECT(
|
||||
UVERBS_OBJECT_COMP_CHANNEL,
|
||||
@@ -3753,7 +3786,7 @@ const struct uapi_definition uverbs_def_write_intf[] = {
|
||||
IB_USER_VERBS_EX_CMD_MODIFY_CQ,
|
||||
ib_uverbs_ex_modify_cq,
|
||||
UAPI_DEF_WRITE_I(struct ib_uverbs_ex_modify_cq),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(create_cq))),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(modify_cq))),
|
||||
|
||||
DECLARE_UVERBS_OBJECT(
|
||||
UVERBS_OBJECT_DEVICE,
|
||||
@@ -3999,8 +4032,7 @@ const struct uapi_definition uverbs_def_write_intf[] = {
|
||||
DECLARE_UVERBS_WRITE(
|
||||
IB_USER_VERBS_CMD_CLOSE_XRCD,
|
||||
ib_uverbs_close_xrcd,
|
||||
UAPI_DEF_WRITE_I(struct ib_uverbs_close_xrcd),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(dealloc_xrcd)),
|
||||
UAPI_DEF_WRITE_I(struct ib_uverbs_close_xrcd)),
|
||||
DECLARE_UVERBS_WRITE(IB_USER_VERBS_CMD_OPEN_QP,
|
||||
ib_uverbs_open_qp,
|
||||
UAPI_DEF_WRITE_UDATA_IO(
|
||||
@@ -4010,8 +4042,9 @@ const struct uapi_definition uverbs_def_write_intf[] = {
|
||||
ib_uverbs_open_xrcd,
|
||||
UAPI_DEF_WRITE_UDATA_IO(
|
||||
struct ib_uverbs_open_xrcd,
|
||||
struct ib_uverbs_open_xrcd_resp),
|
||||
UAPI_DEF_METHOD_NEEDS_FN(alloc_xrcd))),
|
||||
struct ib_uverbs_open_xrcd_resp)),
|
||||
UAPI_DEF_OBJ_NEEDS_FN(alloc_xrcd),
|
||||
UAPI_DEF_OBJ_NEEDS_FN(dealloc_xrcd)),
|
||||
|
||||
{},
|
||||
};
|
||||
|
||||
@@ -1046,7 +1046,7 @@ static ssize_t ibdev_show(struct device *device, struct device_attribute *attr,
|
||||
srcu_key = srcu_read_lock(&dev->disassociate_srcu);
|
||||
ib_dev = srcu_dereference(dev->ib_dev, &dev->disassociate_srcu);
|
||||
if (ib_dev)
|
||||
ret = sprintf(buf, "%s\n", dev_name(&ib_dev->dev));
|
||||
ret = sysfs_emit(buf, "%s\n", dev_name(&ib_dev->dev));
|
||||
srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
|
||||
|
||||
return ret;
|
||||
@@ -1065,7 +1065,7 @@ static ssize_t abi_version_show(struct device *device,
|
||||
srcu_key = srcu_read_lock(&dev->disassociate_srcu);
|
||||
ib_dev = srcu_dereference(dev->ib_dev, &dev->disassociate_srcu);
|
||||
if (ib_dev)
|
||||
ret = sprintf(buf, "%u\n", ib_dev->ops.uverbs_abi_ver);
|
||||
ret = sysfs_emit(buf, "%u\n", ib_dev->ops.uverbs_abi_ver);
|
||||
srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -88,7 +88,7 @@ static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject,
|
||||
return -EBUSY;
|
||||
|
||||
ret = rwq_ind_tbl->device->ops.destroy_rwq_ind_table(rwq_ind_tbl);
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < table_size; i++)
|
||||
@@ -96,7 +96,7 @@ static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject,
|
||||
|
||||
kfree(rwq_ind_tbl);
|
||||
kfree(ind_tbl);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uverbs_free_xrcd(struct ib_uobject *uobject,
|
||||
@@ -108,9 +108,8 @@ static int uverbs_free_xrcd(struct ib_uobject *uobject,
|
||||
container_of(uobject, struct ib_uxrcd_object, uobject);
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&uxrcd->refcnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&uxrcd->refcnt))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&attrs->ufile->device->xrcd_tree_mutex);
|
||||
ret = ib_uverbs_dealloc_xrcd(uobject, xrcd, why, attrs);
|
||||
@@ -124,11 +123,9 @@ static int uverbs_free_pd(struct ib_uobject *uobject,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct ib_pd *pd = uobject->object;
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&pd->usecnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&pd->usecnt))
|
||||
return -EBUSY;
|
||||
|
||||
return ib_dealloc_pd_user(pd, &attrs->driver_udata);
|
||||
}
|
||||
@@ -157,7 +154,7 @@ void ib_uverbs_free_event_queue(struct ib_uverbs_event_queue *event_queue)
|
||||
spin_unlock_irq(&event_queue->lock);
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
uverbs_completion_event_file_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
{
|
||||
@@ -166,7 +163,6 @@ uverbs_completion_event_file_destroy_uobj(struct ib_uobject *uobj,
|
||||
uobj);
|
||||
|
||||
ib_uverbs_free_event_queue(&file->ev_queue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs)
|
||||
|
||||
@@ -19,8 +19,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_ASYNC_EVENT_ALLOC)(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
static void uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
{
|
||||
struct ib_uverbs_async_event_file *event_file =
|
||||
container_of(uobj, struct ib_uverbs_async_event_file, uobj);
|
||||
@@ -30,7 +30,6 @@ static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
if (why == RDMA_REMOVE_DRIVER_REMOVE)
|
||||
ib_uverbs_async_handler(event_file, 0, IB_EVENT_DEVICE_FATAL,
|
||||
NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uverbs_async_event_release(struct inode *inode, struct file *filp)
|
||||
|
||||
@@ -42,9 +42,8 @@ static int uverbs_free_counters(struct ib_uobject *uobject,
|
||||
struct ib_counters *counters = uobject->object;
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&counters->usecnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&counters->usecnt))
|
||||
return -EBUSY;
|
||||
|
||||
ret = counters->device->ops.destroy_counters(counters);
|
||||
if (ret)
|
||||
|
||||
@@ -46,7 +46,7 @@ static int uverbs_free_cq(struct ib_uobject *uobject,
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_cq_user(cq, &attrs->driver_udata);
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ib_uverbs_release_ucq(
|
||||
@@ -55,7 +55,7 @@ static int uverbs_free_cq(struct ib_uobject *uobject,
|
||||
ev_queue) :
|
||||
NULL,
|
||||
ucq);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
|
||||
|
||||
@@ -317,8 +317,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_GID_TABLE)(
|
||||
struct ib_device *ib_dev;
|
||||
size_t user_entry_size;
|
||||
ssize_t num_entries;
|
||||
size_t max_entries;
|
||||
size_t num_bytes;
|
||||
int max_entries;
|
||||
u32 flags;
|
||||
int ret;
|
||||
|
||||
@@ -336,19 +335,16 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_GID_TABLE)(
|
||||
attrs, UVERBS_ATTR_QUERY_GID_TABLE_RESP_ENTRIES,
|
||||
user_entry_size);
|
||||
if (max_entries <= 0)
|
||||
return -EINVAL;
|
||||
return max_entries ?: -EINVAL;
|
||||
|
||||
ucontext = ib_uverbs_get_ucontext(attrs);
|
||||
if (IS_ERR(ucontext))
|
||||
return PTR_ERR(ucontext);
|
||||
ib_dev = ucontext->device;
|
||||
|
||||
if (check_mul_overflow(max_entries, sizeof(*entries), &num_bytes))
|
||||
return -EINVAL;
|
||||
|
||||
entries = uverbs_zalloc(attrs, num_bytes);
|
||||
if (!entries)
|
||||
return -ENOMEM;
|
||||
entries = uverbs_kcalloc(attrs, max_entries, sizeof(*entries));
|
||||
if (IS_ERR(entries))
|
||||
return PTR_ERR(entries);
|
||||
|
||||
num_entries = rdma_query_gid_table(ib_dev, entries, max_entries);
|
||||
if (num_entries < 0)
|
||||
|
||||
@@ -39,11 +39,9 @@ static int uverbs_free_dm(struct ib_uobject *uobject,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct ib_dm *dm = uobject->object;
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&dm->usecnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&dm->usecnt))
|
||||
return -EBUSY;
|
||||
|
||||
return dm->device->ops.dealloc_dm(dm, attrs);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,9 @@ static int uverbs_free_flow_action(struct ib_uobject *uobject,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct ib_flow_action *action = uobject->object;
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&action->usecnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&action->usecnt))
|
||||
return -EBUSY;
|
||||
|
||||
return action->device->ops.destroy_flow_action(action);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "rdma_core.h"
|
||||
#include "uverbs.h"
|
||||
#include <rdma/uverbs_std_types.h>
|
||||
#include "restrack.h"
|
||||
|
||||
static int uverbs_free_mr(struct ib_uobject *uobject,
|
||||
enum rdma_remove_reason why,
|
||||
@@ -114,7 +115,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
|
||||
if (!(attr.access_flags & IB_ZERO_BASED))
|
||||
return -EINVAL;
|
||||
|
||||
ret = ib_check_mr_access(attr.access_flags);
|
||||
ret = ib_check_mr_access(ib_dev, attr.access_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -134,6 +135,9 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
|
||||
atomic_inc(&pd->usecnt);
|
||||
atomic_inc(&dm->usecnt);
|
||||
|
||||
rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR);
|
||||
rdma_restrack_set_name(&mr->res, NULL);
|
||||
rdma_restrack_add(&mr->res);
|
||||
uobj->object = mr;
|
||||
|
||||
uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_REG_DM_MR_HANDLE);
|
||||
|
||||
@@ -32,14 +32,14 @@ static int uverbs_free_qp(struct ib_uobject *uobject,
|
||||
}
|
||||
|
||||
ret = ib_destroy_qp_user(qp, &attrs->driver_udata);
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (uqp->uxrcd)
|
||||
atomic_dec(&uqp->uxrcd->refcnt);
|
||||
|
||||
ib_uverbs_release_uevent(&uqp->uevent);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_creation_flags(enum ib_qp_type qp_type,
|
||||
@@ -251,8 +251,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
|
||||
if (attr.qp_type == IB_QPT_XRC_TGT)
|
||||
qp = ib_create_qp(pd, &attr);
|
||||
else
|
||||
qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata,
|
||||
obj);
|
||||
qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata, obj,
|
||||
NULL);
|
||||
|
||||
if (IS_ERR(qp)) {
|
||||
ret = PTR_ERR(qp);
|
||||
|
||||
@@ -18,7 +18,7 @@ static int uverbs_free_srq(struct ib_uobject *uobject,
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_srq_user(srq, &attrs->driver_udata);
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (srq_type == IB_SRQT_XRC) {
|
||||
@@ -30,7 +30,7 @@ static int uverbs_free_srq(struct ib_uobject *uobject,
|
||||
}
|
||||
|
||||
ib_uverbs_release_uevent(uevent);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int UVERBS_HANDLER(UVERBS_METHOD_SRQ_CREATE)(
|
||||
|
||||
@@ -17,11 +17,11 @@ static int uverbs_free_wq(struct ib_uobject *uobject,
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_wq_user(wq, &attrs->driver_udata);
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ib_uverbs_release_uevent(&uwq->uevent);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int UVERBS_HANDLER(UVERBS_METHOD_WQ_CREATE)(
|
||||
|
||||
@@ -79,10 +79,7 @@ static int uapi_create_write(struct uverbs_api *uapi,
|
||||
|
||||
method_elm->is_ex = def->write.is_ex;
|
||||
method_elm->handler = def->func_write;
|
||||
if (def->write.is_ex)
|
||||
method_elm->disabled = !(ibdev->uverbs_ex_cmd_mask &
|
||||
BIT_ULL(def->write.command_num));
|
||||
else
|
||||
if (!def->write.is_ex)
|
||||
method_elm->disabled = !(ibdev->uverbs_cmd_mask &
|
||||
BIT_ULL(def->write.command_num));
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(rdma_port_get_link_layer);
|
||||
/* Protection domains */
|
||||
|
||||
/**
|
||||
* ib_alloc_pd - Allocates an unused protection domain.
|
||||
* __ib_alloc_pd - Allocates an unused protection domain.
|
||||
* @device: The device on which to allocate the protection domain.
|
||||
* @flags: protection domain flags
|
||||
* @caller: caller's build-time module name
|
||||
@@ -516,7 +516,7 @@ static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
|
||||
|
||||
might_sleep_if(flags & RDMA_CREATE_AH_SLEEPABLE);
|
||||
|
||||
if (!device->ops.create_ah)
|
||||
if (!udata && !device->ops.create_ah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
ah = rdma_zalloc_drv_obj_gfp(
|
||||
@@ -533,7 +533,10 @@ static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
|
||||
init_attr.flags = flags;
|
||||
init_attr.xmit_slave = xmit_slave;
|
||||
|
||||
ret = device->ops.create_ah(ah, &init_attr, udata);
|
||||
if (udata)
|
||||
ret = device->ops.create_user_ah(ah, &init_attr, udata);
|
||||
else
|
||||
ret = device->ops.create_ah(ah, &init_attr, NULL);
|
||||
if (ret) {
|
||||
kfree(ah);
|
||||
return ERR_PTR(ret);
|
||||
@@ -1188,17 +1191,19 @@ static struct ib_qp *create_xrc_qp_user(struct ib_qp *qp,
|
||||
}
|
||||
|
||||
/**
|
||||
* ib_create_qp - Creates a kernel QP associated with the specified protection
|
||||
* ib_create_named_qp - Creates a kernel QP associated with the specified protection
|
||||
* domain.
|
||||
* @pd: The protection domain associated with the QP.
|
||||
* @qp_init_attr: A list of initial attributes required to create the
|
||||
* QP. If QP creation succeeds, then the attributes are updated to
|
||||
* the actual capabilities of the created QP.
|
||||
* @caller: caller's build-time module name
|
||||
*
|
||||
* NOTE: for user qp use ib_create_qp_user with valid udata!
|
||||
*/
|
||||
struct ib_qp *ib_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *qp_init_attr)
|
||||
struct ib_qp *ib_create_named_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *qp_init_attr,
|
||||
const char *caller)
|
||||
{
|
||||
struct ib_device *device = pd ? pd->device : qp_init_attr->xrcd->device;
|
||||
struct ib_qp *qp;
|
||||
@@ -1223,7 +1228,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
|
||||
if (qp_init_attr->cap.max_rdma_ctxs)
|
||||
rdma_rw_init_qp(device, qp_init_attr);
|
||||
|
||||
qp = _ib_create_qp(device, pd, qp_init_attr, NULL, NULL);
|
||||
qp = _ib_create_qp(device, pd, qp_init_attr, NULL, NULL, caller);
|
||||
if (IS_ERR(qp))
|
||||
return qp;
|
||||
|
||||
@@ -1289,7 +1294,7 @@ err:
|
||||
return ERR_PTR(ret);
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL(ib_create_qp);
|
||||
EXPORT_SYMBOL(ib_create_named_qp);
|
||||
|
||||
static const struct {
|
||||
int valid;
|
||||
@@ -1662,7 +1667,7 @@ static bool is_qp_type_connected(const struct ib_qp *qp)
|
||||
qp->qp_type == IB_QPT_XRC_TGT);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* IB core internal function to perform QP attributes modification.
|
||||
*/
|
||||
static int _ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
|
||||
@@ -1698,8 +1703,10 @@ static int _ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
|
||||
slave = rdma_lag_get_ah_roce_slave(qp->device,
|
||||
&attr->ah_attr,
|
||||
GFP_KERNEL);
|
||||
if (IS_ERR(slave))
|
||||
if (IS_ERR(slave)) {
|
||||
ret = PTR_ERR(slave);
|
||||
goto out_av;
|
||||
}
|
||||
attr->xmit_slave = slave;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,10 +1271,12 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
|
||||
}
|
||||
qplqp->mtu = ib_mtu_enum_to_int(iboe_get_mtu(rdev->netdev->mtu));
|
||||
qplqp->dpi = &rdev->dpi_privileged; /* Doorbell page */
|
||||
if (init_attr->create_flags)
|
||||
if (init_attr->create_flags) {
|
||||
ibdev_dbg(&rdev->ibdev,
|
||||
"QP create flags 0x%x not supported",
|
||||
init_attr->create_flags);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* Setup CQs */
|
||||
if (init_attr->send_cq) {
|
||||
@@ -1657,8 +1659,8 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
|
||||
srq->qplib_srq.max_wqe = entries;
|
||||
|
||||
srq->qplib_srq.max_sge = srq_init_attr->attr.max_sge;
|
||||
srq->qplib_srq.wqe_size =
|
||||
bnxt_re_get_rwqe_size(srq->qplib_srq.max_sge);
|
||||
/* 128 byte wqe size for SRQ . So use max sges */
|
||||
srq->qplib_srq.wqe_size = bnxt_re_get_rwqe_size(dev_attr->max_srq_sges);
|
||||
srq->qplib_srq.threshold = srq_init_attr->attr.srq_limit;
|
||||
srq->srq_limit = srq_init_attr->attr.srq_limit;
|
||||
srq->qplib_srq.eventq_hw_ring_id = rdev->nq[0].ring_id;
|
||||
@@ -1829,6 +1831,9 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
|
||||
unsigned int flags;
|
||||
u8 nw_type;
|
||||
|
||||
if (qp_attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
qp->qplib_qp.modify_flags = 0;
|
||||
if (qp_attr_mask & IB_QP_STATE) {
|
||||
curr_qp_state = __to_ib_qp_state(qp->qplib_qp.cur_qp_state);
|
||||
@@ -2078,6 +2083,7 @@ int bnxt_re_query_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
|
||||
goto out;
|
||||
}
|
||||
qp_attr->qp_state = __to_ib_qp_state(qplib_qp->state);
|
||||
qp_attr->cur_qp_state = __to_ib_qp_state(qplib_qp->cur_qp_state);
|
||||
qp_attr->en_sqd_async_notify = qplib_qp->en_sqd_async_notify ? 1 : 0;
|
||||
qp_attr->qp_access_flags = __to_ib_access_flags(qplib_qp->access);
|
||||
qp_attr->pkey_index = qplib_qp->pkey_index;
|
||||
@@ -2827,6 +2833,9 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct bnxt_qplib_nq *nq = NULL;
|
||||
unsigned int nq_alloc_cnt;
|
||||
|
||||
if (attr->flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Validate CQ fields */
|
||||
if (cqe < 1 || cqe > dev_attr->max_cq_wqes) {
|
||||
ibdev_err(&rdev->ibdev, "Failed to create CQ -max exceeded");
|
||||
|
||||
@@ -608,7 +608,7 @@ static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
||||
struct bnxt_re_dev *rdev =
|
||||
rdma_device_to_drv_device(device, struct bnxt_re_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%x\n", rdev->en_dev->pdev->vendor);
|
||||
return sysfs_emit(buf, "0x%x\n", rdev->en_dev->pdev->vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -618,7 +618,7 @@ static ssize_t hca_type_show(struct device *device,
|
||||
struct bnxt_re_dev *rdev =
|
||||
rdma_device_to_drv_device(device, struct bnxt_re_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", rdev->ibdev.node_desc);
|
||||
return sysfs_emit(buf, "%s\n", rdev->ibdev.node_desc);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -646,6 +646,7 @@ static const struct ib_device_ops bnxt_re_dev_ops = {
|
||||
.create_cq = bnxt_re_create_cq,
|
||||
.create_qp = bnxt_re_create_qp,
|
||||
.create_srq = bnxt_re_create_srq,
|
||||
.create_user_ah = bnxt_re_create_ah,
|
||||
.dealloc_driver = bnxt_re_dealloc_driver,
|
||||
.dealloc_pd = bnxt_re_dealloc_pd,
|
||||
.dealloc_ucontext = bnxt_re_dealloc_ucontext,
|
||||
@@ -701,35 +702,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
|
||||
ibdev->dev.parent = &rdev->en_dev->pdev->dev;
|
||||
ibdev->local_dma_lkey = BNXT_QPLIB_RSVD_LKEY;
|
||||
|
||||
/* User space */
|
||||
ibdev->uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_REREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_AH);
|
||||
/* POLL_CQ and REQ_NOTIFY_CQ is directly handled in libbnxt_re */
|
||||
|
||||
|
||||
rdma_set_device_sysfs_group(ibdev, &bnxt_re_dev_attr_group);
|
||||
ib_set_device_ops(ibdev, &bnxt_re_dev_ops);
|
||||
ret = ib_device_set_netdev(&rdev->ibdev, rdev->netdev, 1);
|
||||
|
||||
@@ -118,7 +118,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
|
||||
* 128 WQEs needs to be reserved for the HW (8916). Prevent
|
||||
* reporting the max number
|
||||
*/
|
||||
attr->max_qp_wqes -= BNXT_QPLIB_RESERVED_QP_WRS;
|
||||
attr->max_qp_wqes -= BNXT_QPLIB_RESERVED_QP_WRS + 1;
|
||||
attr->max_qp_sges = bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx) ?
|
||||
6 : sb->max_sge;
|
||||
attr->max_cq = le32_to_cpu(sb->max_cq);
|
||||
|
||||
@@ -1006,6 +1006,9 @@ int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
|
||||
pr_debug("ib_dev %p entries %d\n", ibdev, entries);
|
||||
if (attr->flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (entries < 1 || entries > ibdev->attrs.max_cqe)
|
||||
return -EINVAL;
|
||||
|
||||
if (vector >= rhp->rdev.lldi.nciq)
|
||||
|
||||
@@ -983,9 +983,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
u32 max_num_sg);
|
||||
int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
unsigned int *sg_offset);
|
||||
int c4iw_dealloc_mw(struct ib_mw *mw);
|
||||
void c4iw_dealloc(struct uld_ctx *ctx);
|
||||
int c4iw_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
|
||||
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start,
|
||||
u64 length, u64 virt, int acc,
|
||||
struct ib_udata *udata);
|
||||
|
||||
@@ -365,22 +365,6 @@ static int dereg_mem(struct c4iw_rdev *rdev, u32 stag, u32 pbl_size,
|
||||
pbl_size, pbl_addr, skb, wr_waitp);
|
||||
}
|
||||
|
||||
static int allocate_window(struct c4iw_rdev *rdev, u32 *stag, u32 pdid,
|
||||
struct c4iw_wr_wait *wr_waitp)
|
||||
{
|
||||
*stag = T4_STAG_UNSET;
|
||||
return write_tpt_entry(rdev, 0, stag, 0, pdid, FW_RI_STAG_MW, 0, 0, 0,
|
||||
0UL, 0, 0, 0, 0, NULL, wr_waitp);
|
||||
}
|
||||
|
||||
static int deallocate_window(struct c4iw_rdev *rdev, u32 stag,
|
||||
struct sk_buff *skb,
|
||||
struct c4iw_wr_wait *wr_waitp)
|
||||
{
|
||||
return write_tpt_entry(rdev, 1, &stag, 0, 0, 0, 0, 0, 0, 0UL, 0, 0, 0,
|
||||
0, skb, wr_waitp);
|
||||
}
|
||||
|
||||
static int allocate_stag(struct c4iw_rdev *rdev, u32 *stag, u32 pdid,
|
||||
u32 pbl_size, u32 pbl_addr,
|
||||
struct c4iw_wr_wait *wr_waitp)
|
||||
@@ -611,74 +595,6 @@ err_free_mhp:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
int c4iw_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
|
||||
{
|
||||
struct c4iw_mw *mhp = to_c4iw_mw(ibmw);
|
||||
struct c4iw_dev *rhp;
|
||||
struct c4iw_pd *php;
|
||||
u32 mmid;
|
||||
u32 stag = 0;
|
||||
int ret;
|
||||
|
||||
if (ibmw->type != IB_MW_TYPE_1)
|
||||
return -EINVAL;
|
||||
|
||||
php = to_c4iw_pd(ibmw->pd);
|
||||
rhp = php->rhp;
|
||||
mhp->wr_waitp = c4iw_alloc_wr_wait(GFP_KERNEL);
|
||||
if (!mhp->wr_waitp)
|
||||
return -ENOMEM;
|
||||
|
||||
mhp->dereg_skb = alloc_skb(SGE_MAX_WR_LEN, GFP_KERNEL);
|
||||
if (!mhp->dereg_skb) {
|
||||
ret = -ENOMEM;
|
||||
goto free_wr_wait;
|
||||
}
|
||||
|
||||
ret = allocate_window(&rhp->rdev, &stag, php->pdid, mhp->wr_waitp);
|
||||
if (ret)
|
||||
goto free_skb;
|
||||
|
||||
mhp->rhp = rhp;
|
||||
mhp->attr.pdid = php->pdid;
|
||||
mhp->attr.type = FW_RI_STAG_MW;
|
||||
mhp->attr.stag = stag;
|
||||
mmid = (stag) >> 8;
|
||||
ibmw->rkey = stag;
|
||||
if (xa_insert_irq(&rhp->mrs, mmid, mhp, GFP_KERNEL)) {
|
||||
ret = -ENOMEM;
|
||||
goto dealloc_win;
|
||||
}
|
||||
pr_debug("mmid 0x%x mhp %p stag 0x%x\n", mmid, mhp, stag);
|
||||
return 0;
|
||||
|
||||
dealloc_win:
|
||||
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb,
|
||||
mhp->wr_waitp);
|
||||
free_skb:
|
||||
kfree_skb(mhp->dereg_skb);
|
||||
free_wr_wait:
|
||||
c4iw_put_wr_wait(mhp->wr_waitp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int c4iw_dealloc_mw(struct ib_mw *mw)
|
||||
{
|
||||
struct c4iw_dev *rhp;
|
||||
struct c4iw_mw *mhp;
|
||||
u32 mmid;
|
||||
|
||||
mhp = to_c4iw_mw(mw);
|
||||
rhp = mhp->rhp;
|
||||
mmid = (mw->rkey) >> 8;
|
||||
xa_erase_irq(&rhp->mrs, mmid);
|
||||
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb,
|
||||
mhp->wr_waitp);
|
||||
kfree_skb(mhp->dereg_skb);
|
||||
c4iw_put_wr_wait(mhp->wr_waitp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
u32 max_num_sg)
|
||||
{
|
||||
|
||||
@@ -322,8 +322,9 @@ static ssize_t hw_rev_show(struct device *dev,
|
||||
rdma_device_to_drv_device(dev, struct c4iw_dev, ibdev);
|
||||
|
||||
pr_debug("dev 0x%p\n", dev);
|
||||
return sprintf(buf, "%d\n",
|
||||
CHELSIO_CHIP_RELEASE(c4iw_dev->rdev.lldi.adapter_type));
|
||||
return sysfs_emit(
|
||||
buf, "%d\n",
|
||||
CHELSIO_CHIP_RELEASE(c4iw_dev->rdev.lldi.adapter_type));
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -337,7 +338,7 @@ static ssize_t hca_type_show(struct device *dev,
|
||||
|
||||
pr_debug("dev 0x%p\n", dev);
|
||||
lldev->ethtool_ops->get_drvinfo(lldev, &info);
|
||||
return sprintf(buf, "%s\n", info.driver);
|
||||
return sysfs_emit(buf, "%s\n", info.driver);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -348,8 +349,8 @@ static ssize_t board_id_show(struct device *dev, struct device_attribute *attr,
|
||||
rdma_device_to_drv_device(dev, struct c4iw_dev, ibdev);
|
||||
|
||||
pr_debug("dev 0x%p\n", dev);
|
||||
return sprintf(buf, "%x.%x\n", c4iw_dev->rdev.lldi.pdev->vendor,
|
||||
c4iw_dev->rdev.lldi.pdev->device);
|
||||
return sysfs_emit(buf, "%x.%x\n", c4iw_dev->rdev.lldi.pdev->vendor,
|
||||
c4iw_dev->rdev.lldi.pdev->device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -456,13 +457,11 @@ static const struct ib_device_ops c4iw_dev_ops = {
|
||||
|
||||
.alloc_hw_stats = c4iw_alloc_stats,
|
||||
.alloc_mr = c4iw_alloc_mr,
|
||||
.alloc_mw = c4iw_alloc_mw,
|
||||
.alloc_pd = c4iw_allocate_pd,
|
||||
.alloc_ucontext = c4iw_alloc_ucontext,
|
||||
.create_cq = c4iw_create_cq,
|
||||
.create_qp = c4iw_create_qp,
|
||||
.create_srq = c4iw_create_srq,
|
||||
.dealloc_mw = c4iw_dealloc_mw,
|
||||
.dealloc_pd = c4iw_deallocate_pd,
|
||||
.dealloc_ucontext = c4iw_dealloc_ucontext,
|
||||
.dereg_mr = c4iw_dereg_mr,
|
||||
@@ -533,28 +532,6 @@ void c4iw_register_device(struct work_struct *work)
|
||||
if (fastreg_support)
|
||||
dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
|
||||
dev->ibdev.local_dma_lkey = 0;
|
||||
dev->ibdev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_REQ_NOTIFY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_POLL_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_POST_SEND) |
|
||||
(1ull << IB_USER_VERBS_CMD_POST_RECV) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
|
||||
dev->ibdev.node_type = RDMA_NODE_RNIC;
|
||||
BUILD_BUG_ON(sizeof(C4IW_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX);
|
||||
memcpy(dev->ibdev.node_desc, C4IW_NODE_DESC, sizeof(C4IW_NODE_DESC));
|
||||
|
||||
@@ -2126,7 +2126,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
|
||||
|
||||
pr_debug("ib_pd %p\n", pd);
|
||||
|
||||
if (attrs->qp_type != IB_QPT_RC)
|
||||
if (attrs->qp_type != IB_QPT_RC || attrs->create_flags)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
php = to_c4iw_pd(pd);
|
||||
@@ -2374,6 +2374,9 @@ int c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
|
||||
pr_debug("ib_qp %p\n", ibqp);
|
||||
|
||||
if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* iwarp does not support the RTR state */
|
||||
if ((attr_mask & IB_QP_STATE) && (attr->qp_state == IB_QPS_RTR))
|
||||
attr_mask &= ~IB_QP_STATE;
|
||||
@@ -2680,6 +2683,9 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,
|
||||
int ret;
|
||||
int wr_len;
|
||||
|
||||
if (attrs->srq_type != IB_SRQT_BASIC)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
pr_debug("%s ib_pd %p\n", __func__, pd);
|
||||
|
||||
php = to_c4iw_pd(pd);
|
||||
|
||||
@@ -245,9 +245,9 @@ static const struct ib_device_ops efa_dev_ops = {
|
||||
.alloc_hw_stats = efa_alloc_hw_stats,
|
||||
.alloc_pd = efa_alloc_pd,
|
||||
.alloc_ucontext = efa_alloc_ucontext,
|
||||
.create_ah = efa_create_ah,
|
||||
.create_cq = efa_create_cq,
|
||||
.create_qp = efa_create_qp,
|
||||
.create_user_ah = efa_create_ah,
|
||||
.dealloc_pd = efa_dealloc_pd,
|
||||
.dealloc_ucontext = efa_dealloc_ucontext,
|
||||
.dereg_mr = efa_dereg_mr,
|
||||
@@ -308,27 +308,6 @@ static int efa_ib_device_add(struct efa_dev *dev)
|
||||
dev->ibdev.num_comp_vectors = 1;
|
||||
dev->ibdev.dev.parent = &pdev->dev;
|
||||
|
||||
dev->ibdev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_AH);
|
||||
|
||||
dev->ibdev.uverbs_ex_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE);
|
||||
|
||||
ib_set_device_ops(&dev->ibdev, &efa_dev_ops);
|
||||
|
||||
err = ib_register_device(&dev->ibdev, "efa_%d", &pdev->dev);
|
||||
@@ -405,19 +384,12 @@ static int efa_device_init(struct efa_com_dev *edev, struct pci_dev *pdev)
|
||||
return err;
|
||||
}
|
||||
|
||||
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width));
|
||||
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(dma_width));
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "pci_set_dma_mask failed %d\n", err);
|
||||
dev_err(&pdev->dev, "dma_set_mask_and_coherent failed %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width));
|
||||
if (err) {
|
||||
dev_err(&pdev->dev,
|
||||
"err_pci_set_consistent_dma_mask failed %d\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -917,6 +917,9 @@ int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
|
||||
enum ib_qp_state new_state;
|
||||
int err;
|
||||
|
||||
if (qp_attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (udata->inlen &&
|
||||
!ib_is_udata_cleared(udata, 0, udata->inlen)) {
|
||||
ibdev_dbg(&dev->ibdev,
|
||||
@@ -1029,6 +1032,9 @@ int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
|
||||
ibdev_dbg(ibdev, "create_cq entries %d\n", entries);
|
||||
|
||||
if (attr->flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (entries < 1 || entries > dev->dev_attr.max_cq_depth) {
|
||||
ibdev_dbg(ibdev,
|
||||
"cq: requested entries[%u] non-positive or greater than max[%u]\n",
|
||||
|
||||
@@ -339,6 +339,7 @@ int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe, bool *call_send)
|
||||
return -EINVAL;
|
||||
if (ibp->sl_to_sc[rdma_ah_get_sl(&ah->attr)] == 0xf)
|
||||
return -EINVAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ struct hfi1_port_attr {
|
||||
|
||||
static ssize_t cc_prescan_show(struct hfi1_pportdata *ppd, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%s\n", ppd->cc_prescan ? "on" : "off");
|
||||
return sysfs_emit(buf, "%s\n", ppd->cc_prescan ? "on" : "off");
|
||||
}
|
||||
|
||||
static ssize_t cc_prescan_store(struct hfi1_pportdata *ppd, const char *buf,
|
||||
@@ -296,7 +296,7 @@ static ssize_t sc2vl_attr_show(struct kobject *kobj, struct attribute *attr,
|
||||
container_of(kobj, struct hfi1_pportdata, sc2vl_kobj);
|
||||
struct hfi1_devdata *dd = ppd->dd;
|
||||
|
||||
return sprintf(buf, "%u\n", *((u8 *)dd->sc2vl + sattr->sc));
|
||||
return sysfs_emit(buf, "%u\n", *((u8 *)dd->sc2vl + sattr->sc));
|
||||
}
|
||||
|
||||
static const struct sysfs_ops hfi1_sc2vl_ops = {
|
||||
@@ -401,7 +401,7 @@ static ssize_t sl2sc_attr_show(struct kobject *kobj, struct attribute *attr,
|
||||
container_of(kobj, struct hfi1_pportdata, sl2sc_kobj);
|
||||
struct hfi1_ibport *ibp = &ppd->ibport_data;
|
||||
|
||||
return sprintf(buf, "%u\n", ibp->sl_to_sc[sattr->sl]);
|
||||
return sysfs_emit(buf, "%u\n", ibp->sl_to_sc[sattr->sl]);
|
||||
}
|
||||
|
||||
static const struct sysfs_ops hfi1_sl2sc_ops = {
|
||||
@@ -475,7 +475,7 @@ static ssize_t vl2mtu_attr_show(struct kobject *kobj, struct attribute *attr,
|
||||
container_of(kobj, struct hfi1_pportdata, vl2mtu_kobj);
|
||||
struct hfi1_devdata *dd = ppd->dd;
|
||||
|
||||
return sprintf(buf, "%u\n", dd->vld[vlattr->vl].mtu);
|
||||
return sysfs_emit(buf, "%u\n", dd->vld[vlattr->vl].mtu);
|
||||
}
|
||||
|
||||
static const struct sysfs_ops hfi1_vl2mtu_ops = {
|
||||
@@ -500,7 +500,7 @@ static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
||||
struct hfi1_ibdev *dev =
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
|
||||
return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
|
||||
return sysfs_emit(buf, "%x\n", dd_from_dev(dev)->minrev);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -510,13 +510,11 @@ static ssize_t board_id_show(struct device *device,
|
||||
struct hfi1_ibdev *dev =
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
|
||||
if (!dd->boardname)
|
||||
ret = -EINVAL;
|
||||
else
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%s\n", dd->boardname);
|
||||
return ret;
|
||||
return -EINVAL;
|
||||
|
||||
return sysfs_emit(buf, "%s\n", dd->boardname);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -528,7 +526,7 @@ static ssize_t boardversion_show(struct device *device,
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* The string printed here is already newline-terminated. */
|
||||
return scnprintf(buf, PAGE_SIZE, "%s", dd->boardversion);
|
||||
return sysfs_emit(buf, "%s", dd->boardversion);
|
||||
}
|
||||
static DEVICE_ATTR_RO(boardversion);
|
||||
|
||||
@@ -545,9 +543,9 @@ static ssize_t nctxts_show(struct device *device,
|
||||
* and a receive context, so returning the smaller of the two counts
|
||||
* give a more accurate picture of total contexts available.
|
||||
*/
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n",
|
||||
min(dd->num_user_contexts,
|
||||
(u32)dd->sc_sizes[SC_USER].count));
|
||||
return sysfs_emit(buf, "%u\n",
|
||||
min(dd->num_user_contexts,
|
||||
(u32)dd->sc_sizes[SC_USER].count));
|
||||
}
|
||||
static DEVICE_ATTR_RO(nctxts);
|
||||
|
||||
@@ -559,7 +557,7 @@ static ssize_t nfreectxts_show(struct device *device,
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* Return the number of free user ports (contexts) available. */
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts);
|
||||
return sysfs_emit(buf, "%u\n", dd->freectxts);
|
||||
}
|
||||
static DEVICE_ATTR_RO(nfreectxts);
|
||||
|
||||
@@ -570,7 +568,8 @@ static ssize_t serial_show(struct device *device,
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s", dd->serial);
|
||||
/* dd->serial is already newline terminated in chip.c */
|
||||
return sysfs_emit(buf, "%s", dd->serial);
|
||||
}
|
||||
static DEVICE_ATTR_RO(serial);
|
||||
|
||||
@@ -598,9 +597,8 @@ static DEVICE_ATTR_WO(chip_reset);
|
||||
* Convert the reported temperature from an integer (reported in
|
||||
* units of 0.25C) to a floating point number.
|
||||
*/
|
||||
#define temp2str(temp, buf, size, idx) \
|
||||
scnprintf((buf) + (idx), (size) - (idx), "%u.%02u ", \
|
||||
((temp) >> 2), ((temp) & 0x3) * 25)
|
||||
#define temp_d(t) ((t) >> 2)
|
||||
#define temp_f(t) (((t)&0x3) * 25u)
|
||||
|
||||
/*
|
||||
* Dump tempsense values, in decimal, to ease shell-scripts.
|
||||
@@ -615,19 +613,17 @@ static ssize_t tempsense_show(struct device *device,
|
||||
int ret;
|
||||
|
||||
ret = hfi1_tempsense_rd(dd, &temp);
|
||||
if (!ret) {
|
||||
int idx = 0;
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
idx += temp2str(temp.curr, buf, PAGE_SIZE, idx);
|
||||
idx += temp2str(temp.lo_lim, buf, PAGE_SIZE, idx);
|
||||
idx += temp2str(temp.hi_lim, buf, PAGE_SIZE, idx);
|
||||
idx += temp2str(temp.crit_lim, buf, PAGE_SIZE, idx);
|
||||
idx += scnprintf(buf + idx, PAGE_SIZE - idx,
|
||||
"%u %u %u\n", temp.triggers & 0x1,
|
||||
temp.triggers & 0x2, temp.triggers & 0x4);
|
||||
ret = idx;
|
||||
}
|
||||
return ret;
|
||||
return sysfs_emit(buf, "%u.%02u %u.%02u %u.%02u %u.%02u %u %u %u\n",
|
||||
temp_d(temp.curr), temp_f(temp.curr),
|
||||
temp_d(temp.lo_lim), temp_f(temp.lo_lim),
|
||||
temp_d(temp.hi_lim), temp_f(temp.hi_lim),
|
||||
temp_d(temp.crit_lim), temp_f(temp.crit_lim),
|
||||
temp.triggers & 0x1,
|
||||
temp.triggers & 0x2,
|
||||
temp.triggers & 0x4);
|
||||
}
|
||||
static DEVICE_ATTR_RO(tempsense);
|
||||
|
||||
@@ -817,7 +813,7 @@ static ssize_t sde_show_vl(struct sdma_engine *sde, char *buf)
|
||||
if (vl < 0)
|
||||
return vl;
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", vl);
|
||||
return sysfs_emit(buf, "%d\n", vl);
|
||||
}
|
||||
|
||||
static SDE_ATTR(cpu_list, S_IWUSR | S_IRUGO,
|
||||
|
||||
@@ -2826,6 +2826,7 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3005,6 +3006,7 @@ bool hfi1_handle_kdeth_eflags(struct hfi1_ctxtdata *rcd,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3221,6 +3223,7 @@ bool hfi1_tid_rdma_wqe_interlock(struct rvt_qp *qp, struct rvt_swqe *wqe)
|
||||
req = wqe_to_tid_req(prev);
|
||||
if (req->ack_seg != req->total_segs)
|
||||
goto interlock;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3239,9 +3242,11 @@ bool hfi1_tid_rdma_wqe_interlock(struct rvt_qp *qp, struct rvt_swqe *wqe)
|
||||
req = wqe_to_tid_req(prev);
|
||||
if (req->ack_seg != req->total_segs)
|
||||
goto interlock;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,14 +31,11 @@
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_cache.h>
|
||||
#include "hns_roce_device.h"
|
||||
|
||||
#define HNS_ROCE_PORT_NUM_SHIFT 24
|
||||
#define HNS_ROCE_VLAN_SL_BIT_MASK 7
|
||||
#define HNS_ROCE_VLAN_SL_SHIFT 13
|
||||
|
||||
static inline u16 get_ah_udp_sport(const struct rdma_ah_attr *ah_attr)
|
||||
{
|
||||
u32 fl = ah_attr->grh.flow_label;
|
||||
@@ -58,47 +55,41 @@ static inline u16 get_ah_udp_sport(const struct rdma_ah_attr *ah_attr)
|
||||
int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device);
|
||||
const struct ib_gid_attr *gid_attr;
|
||||
struct device *dev = hr_dev->dev;
|
||||
struct hns_roce_ah *ah = to_hr_ah(ibah);
|
||||
struct rdma_ah_attr *ah_attr = init_attr->ah_attr;
|
||||
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
|
||||
u16 vlan_id = 0xffff;
|
||||
bool vlan_en = false;
|
||||
int ret;
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device);
|
||||
struct hns_roce_ah *ah = to_hr_ah(ibah);
|
||||
int ret = 0;
|
||||
|
||||
gid_attr = ah_attr->grh.sgid_attr;
|
||||
ret = rdma_read_gid_l2_fields(gid_attr, &vlan_id, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Get mac address */
|
||||
memcpy(ah->av.mac, ah_attr->roce.dmac, ETH_ALEN);
|
||||
|
||||
if (vlan_id < VLAN_N_VID) {
|
||||
vlan_en = true;
|
||||
vlan_id |= (rdma_ah_get_sl(ah_attr) &
|
||||
HNS_ROCE_VLAN_SL_BIT_MASK) <<
|
||||
HNS_ROCE_VLAN_SL_SHIFT;
|
||||
}
|
||||
if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 && udata)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ah->av.port = rdma_ah_get_port_num(ah_attr);
|
||||
ah->av.gid_index = grh->sgid_index;
|
||||
ah->av.vlan_id = vlan_id;
|
||||
ah->av.vlan_en = vlan_en;
|
||||
dev_dbg(dev, "gid_index = 0x%x,vlan_id = 0x%x\n", ah->av.gid_index,
|
||||
ah->av.vlan_id);
|
||||
|
||||
if (rdma_ah_get_static_rate(ah_attr))
|
||||
ah->av.stat_rate = IB_RATE_10_GBPS;
|
||||
|
||||
memcpy(ah->av.dgid, grh->dgid.raw, HNS_ROCE_GID_SIZE);
|
||||
ah->av.sl = rdma_ah_get_sl(ah_attr);
|
||||
ah->av.hop_limit = grh->hop_limit;
|
||||
ah->av.flowlabel = grh->flow_label;
|
||||
ah->av.udp_sport = get_ah_udp_sport(ah_attr);
|
||||
ah->av.sl = rdma_ah_get_sl(ah_attr);
|
||||
ah->av.tclass = get_tclass(grh);
|
||||
|
||||
return 0;
|
||||
memcpy(ah->av.dgid, grh->dgid.raw, HNS_ROCE_GID_SIZE);
|
||||
memcpy(ah->av.mac, ah_attr->roce.dmac, ETH_ALEN);
|
||||
|
||||
/* HIP08 needs to record vlan info in Address Vector */
|
||||
if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08) {
|
||||
ret = rdma_read_gid_l2_fields(ah_attr->grh.sgid_attr,
|
||||
&ah->av.vlan_id, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ah->av.vlan_en = ah->av.vlan_id < VLAN_N_VID;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hns_roce_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
|
||||
|
||||
@@ -159,76 +159,96 @@ void hns_roce_bitmap_cleanup(struct hns_roce_bitmap *bitmap)
|
||||
|
||||
void hns_roce_buf_free(struct hns_roce_dev *hr_dev, struct hns_roce_buf *buf)
|
||||
{
|
||||
struct device *dev = hr_dev->dev;
|
||||
u32 size = buf->size;
|
||||
int i;
|
||||
struct hns_roce_buf_list *trunks;
|
||||
u32 i;
|
||||
|
||||
if (size == 0)
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
buf->size = 0;
|
||||
trunks = buf->trunk_list;
|
||||
if (trunks) {
|
||||
buf->trunk_list = NULL;
|
||||
for (i = 0; i < buf->ntrunks; i++)
|
||||
dma_free_coherent(hr_dev->dev, 1 << buf->trunk_shift,
|
||||
trunks[i].buf, trunks[i].map);
|
||||
|
||||
if (hns_roce_buf_is_direct(buf)) {
|
||||
dma_free_coherent(dev, size, buf->direct.buf, buf->direct.map);
|
||||
} else {
|
||||
for (i = 0; i < buf->npages; ++i)
|
||||
if (buf->page_list[i].buf)
|
||||
dma_free_coherent(dev, 1 << buf->page_shift,
|
||||
buf->page_list[i].buf,
|
||||
buf->page_list[i].map);
|
||||
kfree(buf->page_list);
|
||||
buf->page_list = NULL;
|
||||
kfree(trunks);
|
||||
}
|
||||
|
||||
kfree(buf);
|
||||
}
|
||||
|
||||
int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
|
||||
struct hns_roce_buf *buf, u32 page_shift)
|
||||
/*
|
||||
* Allocate the dma buffer for storing ROCEE table entries
|
||||
*
|
||||
* @size: required size
|
||||
* @page_shift: the unit size in a continuous dma address range
|
||||
* @flags: HNS_ROCE_BUF_ flags to control the allocation flow.
|
||||
*/
|
||||
struct hns_roce_buf *hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size,
|
||||
u32 page_shift, u32 flags)
|
||||
{
|
||||
struct hns_roce_buf_list *buf_list;
|
||||
struct device *dev = hr_dev->dev;
|
||||
u32 page_size;
|
||||
int i;
|
||||
u32 trunk_size, page_size, alloced_size;
|
||||
struct hns_roce_buf_list *trunks;
|
||||
struct hns_roce_buf *buf;
|
||||
gfp_t gfp_flags;
|
||||
u32 ntrunk, i;
|
||||
|
||||
/* The minimum shift of the page accessed by hw is HNS_HW_PAGE_SHIFT */
|
||||
buf->page_shift = max_t(int, HNS_HW_PAGE_SHIFT, page_shift);
|
||||
if (WARN_ON(page_shift < HNS_HW_PAGE_SHIFT))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
gfp_flags = (flags & HNS_ROCE_BUF_NOSLEEP) ? GFP_ATOMIC : GFP_KERNEL;
|
||||
buf = kzalloc(sizeof(*buf), gfp_flags);
|
||||
if (!buf)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
buf->page_shift = page_shift;
|
||||
page_size = 1 << buf->page_shift;
|
||||
buf->npages = DIV_ROUND_UP(size, page_size);
|
||||
|
||||
/* required size is not bigger than one trunk size */
|
||||
if (size <= max_direct) {
|
||||
buf->page_list = NULL;
|
||||
buf->direct.buf = dma_alloc_coherent(dev, size,
|
||||
&buf->direct.map,
|
||||
GFP_KERNEL);
|
||||
if (!buf->direct.buf)
|
||||
return -ENOMEM;
|
||||
/* Calc the trunk size and num by required size and page_shift */
|
||||
if (flags & HNS_ROCE_BUF_DIRECT) {
|
||||
buf->trunk_shift = ilog2(ALIGN(size, PAGE_SIZE));
|
||||
ntrunk = 1;
|
||||
} else {
|
||||
buf_list = kcalloc(buf->npages, sizeof(*buf_list), GFP_KERNEL);
|
||||
if (!buf_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < buf->npages; i++) {
|
||||
buf_list[i].buf = dma_alloc_coherent(dev, page_size,
|
||||
&buf_list[i].map,
|
||||
GFP_KERNEL);
|
||||
if (!buf_list[i].buf)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i != buf->npages && i > 0) {
|
||||
while (i-- > 0)
|
||||
dma_free_coherent(dev, page_size,
|
||||
buf_list[i].buf,
|
||||
buf_list[i].map);
|
||||
kfree(buf_list);
|
||||
return -ENOMEM;
|
||||
}
|
||||
buf->page_list = buf_list;
|
||||
buf->trunk_shift = ilog2(ALIGN(page_size, PAGE_SIZE));
|
||||
ntrunk = DIV_ROUND_UP(size, 1 << buf->trunk_shift);
|
||||
}
|
||||
buf->size = size;
|
||||
|
||||
return 0;
|
||||
trunks = kcalloc(ntrunk, sizeof(*trunks), gfp_flags);
|
||||
if (!trunks) {
|
||||
kfree(buf);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
trunk_size = 1 << buf->trunk_shift;
|
||||
alloced_size = 0;
|
||||
for (i = 0; i < ntrunk; i++) {
|
||||
trunks[i].buf = dma_alloc_coherent(hr_dev->dev, trunk_size,
|
||||
&trunks[i].map, gfp_flags);
|
||||
if (!trunks[i].buf)
|
||||
break;
|
||||
|
||||
alloced_size += trunk_size;
|
||||
}
|
||||
|
||||
buf->ntrunks = i;
|
||||
|
||||
/* In nofail mode, it's only failed when the alloced size is 0 */
|
||||
if ((flags & HNS_ROCE_BUF_NOFAIL) ? i == 0 : i != ntrunk) {
|
||||
for (i = 0; i < buf->ntrunks; i++)
|
||||
dma_free_coherent(hr_dev->dev, trunk_size,
|
||||
trunks[i].buf, trunks[i].map);
|
||||
|
||||
kfree(trunks);
|
||||
kfree(buf);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
buf->npages = DIV_ROUND_UP(alloced_size, page_size);
|
||||
buf->trunk_list = trunks;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
|
||||
@@ -240,7 +260,7 @@ int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
|
||||
end = start + buf_cnt;
|
||||
if (end > buf->npages) {
|
||||
dev_err(hr_dev->dev,
|
||||
"Failed to check kmem bufs, end %d + %d total %d!\n",
|
||||
"failed to check kmem bufs, end %d + %d total %u!\n",
|
||||
start, buf_cnt, buf->npages);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -262,7 +282,7 @@ int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
|
||||
u64 addr;
|
||||
|
||||
if (page_shift < HNS_HW_PAGE_SHIFT) {
|
||||
dev_err(hr_dev->dev, "Failed to check umem page shift %d!\n",
|
||||
dev_err(hr_dev->dev, "failed to check umem page shift %u!\n",
|
||||
page_shift);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
#include "hns_roce_device.h"
|
||||
#include "hns_roce_cmd.h"
|
||||
|
||||
#define CMD_POLL_TOKEN 0xffff
|
||||
#define CMD_MAX_NUM 32
|
||||
#define CMD_TOKEN_MASK 0x1f
|
||||
#define CMD_POLL_TOKEN 0xffff
|
||||
#define CMD_MAX_NUM 32
|
||||
#define CMD_TOKEN_MASK 0x1f
|
||||
|
||||
static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, u32 in_modifier,
|
||||
@@ -60,7 +60,7 @@ static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, unsigned long in_modifier,
|
||||
u8 op_modifier, u16 op,
|
||||
unsigned long timeout)
|
||||
unsigned int timeout)
|
||||
{
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret;
|
||||
@@ -78,7 +78,7 @@ static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
|
||||
static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, unsigned long in_modifier,
|
||||
u8 op_modifier, u16 op, unsigned long timeout)
|
||||
u8 op_modifier, u16 op, unsigned int timeout)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -93,8 +93,8 @@ static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status,
|
||||
u64 out_param)
|
||||
{
|
||||
struct hns_roce_cmd_context
|
||||
*context = &hr_dev->cmd.context[token & hr_dev->cmd.token_mask];
|
||||
struct hns_roce_cmd_context *context =
|
||||
&hr_dev->cmd.context[token % hr_dev->cmd.max_cmds];
|
||||
|
||||
if (token != context->token)
|
||||
return;
|
||||
@@ -108,7 +108,7 @@ void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status,
|
||||
static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, unsigned long in_modifier,
|
||||
u8 op_modifier, u16 op,
|
||||
unsigned long timeout)
|
||||
unsigned int timeout)
|
||||
{
|
||||
struct hns_roce_cmdq *cmd = &hr_dev->cmd;
|
||||
struct hns_roce_cmd_context *context;
|
||||
@@ -159,13 +159,13 @@ out:
|
||||
|
||||
static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, unsigned long in_modifier,
|
||||
u8 op_modifier, u16 op, unsigned long timeout)
|
||||
u8 op_modifier, u16 op, unsigned int timeout)
|
||||
{
|
||||
int ret;
|
||||
|
||||
down(&hr_dev->cmd.event_sem);
|
||||
ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
|
||||
in_modifier, op_modifier, op, timeout);
|
||||
ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, in_modifier,
|
||||
op_modifier, op, timeout);
|
||||
up(&hr_dev->cmd.event_sem);
|
||||
|
||||
return ret;
|
||||
@@ -173,7 +173,7 @@ static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
|
||||
int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
|
||||
unsigned long in_modifier, u8 op_modifier, u16 op,
|
||||
unsigned long timeout)
|
||||
unsigned int timeout)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -231,9 +231,8 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev)
|
||||
struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
|
||||
int i;
|
||||
|
||||
hr_cmd->context = kmalloc_array(hr_cmd->max_cmds,
|
||||
sizeof(*hr_cmd->context),
|
||||
GFP_KERNEL);
|
||||
hr_cmd->context =
|
||||
kcalloc(hr_cmd->max_cmds, sizeof(*hr_cmd->context), GFP_KERNEL);
|
||||
if (!hr_cmd->context)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -262,8 +261,8 @@ void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev)
|
||||
hr_cmd->use_events = 0;
|
||||
}
|
||||
|
||||
struct hns_roce_cmd_mailbox
|
||||
*hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev)
|
||||
struct hns_roce_cmd_mailbox *
|
||||
hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
struct hns_roce_cmd_mailbox *mailbox;
|
||||
|
||||
@@ -271,8 +270,8 @@ struct hns_roce_cmd_mailbox
|
||||
if (!mailbox)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mailbox->buf = dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL,
|
||||
&mailbox->dma);
|
||||
mailbox->buf =
|
||||
dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL, &mailbox->dma);
|
||||
if (!mailbox->buf) {
|
||||
kfree(mailbox);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -141,10 +141,10 @@ enum {
|
||||
|
||||
int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
|
||||
unsigned long in_modifier, u8 op_modifier, u16 op,
|
||||
unsigned long timeout);
|
||||
unsigned int timeout);
|
||||
|
||||
struct hns_roce_cmd_mailbox
|
||||
*hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev);
|
||||
struct hns_roce_cmd_mailbox *
|
||||
hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev);
|
||||
void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_cmd_mailbox *mailbox);
|
||||
|
||||
|
||||
@@ -38,21 +38,33 @@
|
||||
#define roce_raw_write(value, addr) \
|
||||
__raw_writel((__force u32)cpu_to_le32(value), (addr))
|
||||
|
||||
#define roce_get_field(origin, mask, shift) \
|
||||
(((le32_to_cpu(origin)) & (mask)) >> (shift))
|
||||
#define roce_get_field(origin, mask, shift) \
|
||||
((le32_to_cpu(origin) & (mask)) >> (u32)(shift))
|
||||
|
||||
#define roce_get_bit(origin, shift) \
|
||||
roce_get_field((origin), (1ul << (shift)), (shift))
|
||||
|
||||
#define roce_set_field(origin, mask, shift, val) \
|
||||
do { \
|
||||
(origin) &= ~cpu_to_le32(mask); \
|
||||
(origin) |= cpu_to_le32(((u32)(val) << (shift)) & (mask)); \
|
||||
#define roce_set_field(origin, mask, shift, val) \
|
||||
do { \
|
||||
(origin) &= ~cpu_to_le32(mask); \
|
||||
(origin) |= cpu_to_le32(((u32)(val) << (u32)(shift)) & (mask)); \
|
||||
} while (0)
|
||||
|
||||
#define roce_set_bit(origin, shift, val) \
|
||||
#define roce_set_bit(origin, shift, val) \
|
||||
roce_set_field((origin), (1ul << (shift)), (shift), (val))
|
||||
|
||||
#define FIELD_LOC(field_type, field_h, field_l) field_type, field_h, field_l
|
||||
|
||||
#define _hr_reg_enable(ptr, field_type, field_h, field_l) \
|
||||
({ \
|
||||
const field_type *_ptr = ptr; \
|
||||
*((__le32 *)_ptr + (field_h) / 32) |= \
|
||||
cpu_to_le32(BIT((field_l) % 32)) + \
|
||||
BUILD_BUG_ON_ZERO((field_h) != (field_l)); \
|
||||
})
|
||||
|
||||
#define hr_reg_enable(ptr, field) _hr_reg_enable(ptr, field)
|
||||
|
||||
#define ROCEE_GLB_CFG_ROCEE_DB_SQ_MODE_S 3
|
||||
#define ROCEE_GLB_CFG_ROCEE_DB_OTH_MODE_S 4
|
||||
|
||||
|
||||
@@ -36,43 +36,42 @@
|
||||
#include "hns_roce_device.h"
|
||||
#include "hns_roce_cmd.h"
|
||||
#include "hns_roce_hem.h"
|
||||
#include <rdma/hns-abi.h>
|
||||
#include "hns_roce_common.h"
|
||||
|
||||
static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
|
||||
{
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
struct hns_roce_cmd_mailbox *mailbox;
|
||||
struct hns_roce_cq_table *cq_table;
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
u64 mtts[MTT_MIN_COUNT] = { 0 };
|
||||
dma_addr_t dma_handle;
|
||||
int ret;
|
||||
|
||||
ret = hns_roce_mtr_find(hr_dev, &hr_cq->mtr, 0, mtts, ARRAY_SIZE(mtts),
|
||||
&dma_handle);
|
||||
if (ret < 1) {
|
||||
ibdev_err(ibdev, "Failed to find CQ mtr\n");
|
||||
if (!ret) {
|
||||
ibdev_err(ibdev, "failed to find CQ mtr, ret = %d.\n", ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cq_table = &hr_dev->cq_table;
|
||||
ret = hns_roce_bitmap_alloc(&cq_table->bitmap, &hr_cq->cqn);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc CQ bitmap, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to alloc CQ bitmap, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get CQC memory HEM(Hardware Entry Memory) table */
|
||||
ret = hns_roce_table_get(hr_dev, &cq_table->table, hr_cq->cqn);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to get CQ(0x%lx) context, err %d\n",
|
||||
ibdev_err(ibdev, "failed to get CQ(0x%lx) context, ret = %d.\n",
|
||||
hr_cq->cqn, ret);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL));
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to xa_store CQ\n");
|
||||
ibdev_err(ibdev, "failed to xa_store CQ, ret = %d.\n", ret);
|
||||
goto err_put;
|
||||
}
|
||||
|
||||
@@ -91,7 +90,7 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
|
||||
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev,
|
||||
"Failed to send create cmd for CQ(0x%lx), err %d\n",
|
||||
"failed to send create cmd for CQ(0x%lx), ret = %d.\n",
|
||||
hr_cq->cqn, ret);
|
||||
goto err_xa;
|
||||
}
|
||||
@@ -147,7 +146,7 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq,
|
||||
{
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
struct hns_roce_buf_attr buf_attr = {};
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
buf_attr.page_shift = hr_dev->caps.cqe_buf_pg_sz + HNS_HW_PAGE_SHIFT;
|
||||
buf_attr.region[0].size = hr_cq->cq_depth * hr_cq->cqe_size;
|
||||
@@ -155,13 +154,13 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq,
|
||||
buf_attr.region_count = 1;
|
||||
buf_attr.fixed_page = true;
|
||||
|
||||
err = hns_roce_mtr_create(hr_dev, &hr_cq->mtr, &buf_attr,
|
||||
ret = hns_roce_mtr_create(hr_dev, &hr_cq->mtr, &buf_attr,
|
||||
hr_dev->caps.cqe_ba_pg_sz + HNS_HW_PAGE_SHIFT,
|
||||
udata, addr);
|
||||
if (err)
|
||||
ibdev_err(ibdev, "Failed to alloc CQ mtr, err %d\n", err);
|
||||
if (ret)
|
||||
ibdev_err(ibdev, "failed to alloc CQ mtr, ret = %d.\n", ret);
|
||||
|
||||
return err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void free_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
|
||||
@@ -251,14 +250,17 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
|
||||
u32 cq_entries = attr->cqe;
|
||||
int ret;
|
||||
|
||||
if (attr->flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (cq_entries < 1 || cq_entries > hr_dev->caps.max_cqes) {
|
||||
ibdev_err(ibdev, "Failed to check CQ count %d max=%d\n",
|
||||
ibdev_err(ibdev, "failed to check CQ count %u, max = %u.\n",
|
||||
cq_entries, hr_dev->caps.max_cqes);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (vector >= hr_dev->caps.num_comp_vectors) {
|
||||
ibdev_err(ibdev, "Failed to check CQ vector=%d max=%d\n",
|
||||
ibdev_err(ibdev, "failed to check CQ vector = %d, max = %d.\n",
|
||||
vector, hr_dev->caps.num_comp_vectors);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -274,9 +276,9 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
|
||||
|
||||
if (udata) {
|
||||
ret = ib_copy_from_udata(&ucmd, udata,
|
||||
min(sizeof(ucmd), udata->inlen));
|
||||
min(udata->inlen, sizeof(ucmd)));
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to copy CQ udata, err %d\n",
|
||||
ibdev_err(ibdev, "failed to copy CQ udata, ret = %d.\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -286,19 +288,20 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
|
||||
|
||||
ret = alloc_cq_buf(hr_dev, hr_cq, udata, ucmd.buf_addr);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc CQ buf, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to alloc CQ buf, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = alloc_cq_db(hr_dev, hr_cq, udata, ucmd.db_addr, &resp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc CQ db, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to alloc CQ db, ret = %d.\n", ret);
|
||||
goto err_cq_buf;
|
||||
}
|
||||
|
||||
ret = alloc_cqc(hr_dev, hr_cq);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc CQ context, err %d\n", ret);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc CQ context, ret = %d.\n", ret);
|
||||
goto err_cq_db;
|
||||
}
|
||||
|
||||
@@ -313,7 +316,8 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
|
||||
|
||||
if (udata) {
|
||||
resp.cqn = hr_cq->cqn;
|
||||
ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
ret = ib_copy_to_udata(udata, &resp,
|
||||
min(udata->outlen, sizeof(resp)));
|
||||
if (ret)
|
||||
goto err_cqc;
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ static struct hns_roce_db_pgdir *hns_roce_alloc_db_pgdir(
|
||||
static int hns_roce_alloc_db_from_pgdir(struct hns_roce_db_pgdir *pgdir,
|
||||
struct hns_roce_db *db, int order)
|
||||
{
|
||||
int o;
|
||||
int i;
|
||||
unsigned long o;
|
||||
unsigned long i;
|
||||
|
||||
for (o = order; o <= 1; ++o) {
|
||||
i = find_first_bit(pgdir->bits[o], HNS_ROCE_DB_PER_PAGE >> o);
|
||||
@@ -154,8 +154,8 @@ out:
|
||||
|
||||
void hns_roce_free_db(struct hns_roce_dev *hr_dev, struct hns_roce_db *db)
|
||||
{
|
||||
int o;
|
||||
int i;
|
||||
unsigned long o;
|
||||
unsigned long i;
|
||||
|
||||
mutex_lock(&hr_dev->pgdir_mutex);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#define _HNS_ROCE_DEVICE_H
|
||||
|
||||
#include <rdma/ib_verbs.h>
|
||||
#include <rdma/hns-abi.h>
|
||||
|
||||
#define DRV_NAME "hns_roce"
|
||||
|
||||
@@ -117,6 +118,8 @@
|
||||
#define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
|
||||
#define SRQ_DB_REG 0x230
|
||||
|
||||
#define HNS_ROCE_QP_BANK_NUM 8
|
||||
|
||||
/* The chip implementation of the consumer index is calculated
|
||||
* according to twice the actual EQ depth
|
||||
*/
|
||||
@@ -129,15 +132,6 @@ enum {
|
||||
SERV_TYPE_UD,
|
||||
};
|
||||
|
||||
enum {
|
||||
HNS_ROCE_QP_CAP_RQ_RECORD_DB = BIT(0),
|
||||
HNS_ROCE_QP_CAP_SQ_RECORD_DB = BIT(1),
|
||||
};
|
||||
|
||||
enum hns_roce_cq_flags {
|
||||
HNS_ROCE_CQ_FLAG_RECORD_DB = BIT(0),
|
||||
};
|
||||
|
||||
enum hns_roce_qp_state {
|
||||
HNS_ROCE_QP_STATE_RST,
|
||||
HNS_ROCE_QP_STATE_INIT,
|
||||
@@ -166,7 +160,6 @@ enum hns_roce_event {
|
||||
/* 0x10 and 0x11 is unused in currently application case */
|
||||
HNS_ROCE_EVENT_TYPE_DB_OVERFLOW = 0x12,
|
||||
HNS_ROCE_EVENT_TYPE_MB = 0x13,
|
||||
HNS_ROCE_EVENT_TYPE_CEQ_OVERFLOW = 0x14,
|
||||
HNS_ROCE_EVENT_TYPE_FLR = 0x15,
|
||||
};
|
||||
|
||||
@@ -221,6 +214,8 @@ enum {
|
||||
HNS_ROCE_CAP_FLAG_FRMR = BIT(8),
|
||||
HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL = BIT(9),
|
||||
HNS_ROCE_CAP_FLAG_ATOMIC = BIT(10),
|
||||
HNS_ROCE_CAP_FLAG_SDI_MODE = BIT(14),
|
||||
HNS_ROCE_CAP_FLAG_STASH = BIT(17),
|
||||
};
|
||||
|
||||
#define HNS_ROCE_DB_TYPE_COUNT 2
|
||||
@@ -265,9 +260,6 @@ enum {
|
||||
#define HNS_HW_PAGE_SHIFT 12
|
||||
#define HNS_HW_PAGE_SIZE (1 << HNS_HW_PAGE_SHIFT)
|
||||
|
||||
/* The minimum page count for hardware access page directly. */
|
||||
#define HNS_HW_DIRECT_PAGE_COUNT 2
|
||||
|
||||
struct hns_roce_uar {
|
||||
u64 pfn;
|
||||
unsigned long index;
|
||||
@@ -318,7 +310,7 @@ struct hns_roce_hem_table {
|
||||
};
|
||||
|
||||
struct hns_roce_buf_region {
|
||||
int offset; /* page offset */
|
||||
u32 offset; /* page offset */
|
||||
u32 count; /* page count */
|
||||
int hopnum; /* addressing hop num */
|
||||
};
|
||||
@@ -338,10 +330,10 @@ struct hns_roce_buf_attr {
|
||||
size_t size; /* region size */
|
||||
int hopnum; /* multi-hop addressing hop num */
|
||||
} region[HNS_ROCE_MAX_BT_REGION];
|
||||
int region_count; /* valid region count */
|
||||
unsigned int region_count; /* valid region count */
|
||||
unsigned int page_shift; /* buffer page shift */
|
||||
bool fixed_page; /* decide page shift is fixed-size or maximum size */
|
||||
int user_access; /* umem access flag */
|
||||
unsigned int user_access; /* umem access flag */
|
||||
bool mtt_only; /* only alloc buffer-required MTT memory */
|
||||
};
|
||||
|
||||
@@ -352,7 +344,7 @@ struct hns_roce_hem_cfg {
|
||||
unsigned int buf_pg_shift; /* buffer page shift */
|
||||
unsigned int buf_pg_count; /* buffer page count */
|
||||
struct hns_roce_buf_region region[HNS_ROCE_MAX_BT_REGION];
|
||||
int region_count;
|
||||
unsigned int region_count;
|
||||
};
|
||||
|
||||
/* memory translate region */
|
||||
@@ -400,7 +392,7 @@ struct hns_roce_wq {
|
||||
u64 *wrid; /* Work request ID */
|
||||
spinlock_t lock;
|
||||
u32 wqe_cnt; /* WQE num */
|
||||
int max_gs;
|
||||
u32 max_gs;
|
||||
int offset;
|
||||
int wqe_shift; /* WQE size */
|
||||
u32 head;
|
||||
@@ -419,11 +411,26 @@ struct hns_roce_buf_list {
|
||||
dma_addr_t map;
|
||||
};
|
||||
|
||||
/*
|
||||
* %HNS_ROCE_BUF_DIRECT indicates that the all memory must be in a continuous
|
||||
* dma address range.
|
||||
*
|
||||
* %HNS_ROCE_BUF_NOSLEEP indicates that the caller cannot sleep.
|
||||
*
|
||||
* %HNS_ROCE_BUF_NOFAIL allocation only failed when allocated size is zero, even
|
||||
* the allocated size is smaller than the required size.
|
||||
*/
|
||||
enum {
|
||||
HNS_ROCE_BUF_DIRECT = BIT(0),
|
||||
HNS_ROCE_BUF_NOSLEEP = BIT(1),
|
||||
HNS_ROCE_BUF_NOFAIL = BIT(2),
|
||||
};
|
||||
|
||||
struct hns_roce_buf {
|
||||
struct hns_roce_buf_list direct;
|
||||
struct hns_roce_buf_list *page_list;
|
||||
struct hns_roce_buf_list *trunk_list;
|
||||
u32 ntrunks;
|
||||
u32 npages;
|
||||
u32 size;
|
||||
unsigned int trunk_shift;
|
||||
unsigned int page_shift;
|
||||
};
|
||||
|
||||
@@ -451,8 +458,8 @@ struct hns_roce_db {
|
||||
} u;
|
||||
dma_addr_t dma;
|
||||
void *virt_addr;
|
||||
int index;
|
||||
int order;
|
||||
unsigned long index;
|
||||
unsigned long order;
|
||||
};
|
||||
|
||||
struct hns_roce_cq {
|
||||
@@ -500,8 +507,8 @@ struct hns_roce_srq {
|
||||
u64 *wrid;
|
||||
struct hns_roce_idx_que idx_que;
|
||||
spinlock_t lock;
|
||||
int head;
|
||||
int tail;
|
||||
u16 head;
|
||||
u16 tail;
|
||||
struct mutex mutex;
|
||||
void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
|
||||
};
|
||||
@@ -510,13 +517,22 @@ struct hns_roce_uar_table {
|
||||
struct hns_roce_bitmap bitmap;
|
||||
};
|
||||
|
||||
struct hns_roce_bank {
|
||||
struct ida ida;
|
||||
u32 inuse; /* Number of IDs allocated */
|
||||
u32 min; /* Lowest ID to allocate. */
|
||||
u32 max; /* Highest ID to allocate. */
|
||||
u32 next; /* Next ID to allocate. */
|
||||
};
|
||||
|
||||
struct hns_roce_qp_table {
|
||||
struct hns_roce_bitmap bitmap;
|
||||
struct hns_roce_hem_table qp_table;
|
||||
struct hns_roce_hem_table irrl_table;
|
||||
struct hns_roce_hem_table trrl_table;
|
||||
struct hns_roce_hem_table sccc_table;
|
||||
struct mutex scc_mutex;
|
||||
struct hns_roce_bank bank[HNS_ROCE_QP_BANK_NUM];
|
||||
spinlock_t bank_lock;
|
||||
};
|
||||
|
||||
struct hns_roce_cq_table {
|
||||
@@ -547,7 +563,7 @@ struct hns_roce_av {
|
||||
u8 dgid[HNS_ROCE_GID_SIZE];
|
||||
u8 mac[ETH_ALEN];
|
||||
u16 vlan_id;
|
||||
bool vlan_en;
|
||||
u8 vlan_en;
|
||||
};
|
||||
|
||||
struct hns_roce_ah {
|
||||
@@ -619,10 +635,9 @@ enum {
|
||||
struct hns_roce_work {
|
||||
struct hns_roce_dev *hr_dev;
|
||||
struct work_struct work;
|
||||
u32 qpn;
|
||||
u32 cqn;
|
||||
int event_type;
|
||||
int sub_type;
|
||||
u32 queue_num;
|
||||
};
|
||||
|
||||
struct hns_roce_qp {
|
||||
@@ -690,28 +705,10 @@ struct hns_roce_aeqe {
|
||||
__le32 asyn;
|
||||
union {
|
||||
struct {
|
||||
__le32 qp;
|
||||
__le32 num;
|
||||
u32 rsv0;
|
||||
u32 rsv1;
|
||||
} qp_event;
|
||||
|
||||
struct {
|
||||
__le32 srq;
|
||||
u32 rsv0;
|
||||
u32 rsv1;
|
||||
} srq_event;
|
||||
|
||||
struct {
|
||||
__le32 cq;
|
||||
u32 rsv0;
|
||||
u32 rsv1;
|
||||
} cq_event;
|
||||
|
||||
struct {
|
||||
__le32 ceqe;
|
||||
u32 rsv0;
|
||||
u32 rsv1;
|
||||
} ce_event;
|
||||
} queue_event;
|
||||
|
||||
struct {
|
||||
__le64 out_param;
|
||||
@@ -730,11 +727,11 @@ struct hns_roce_eq {
|
||||
int type_flag; /* Aeq:1 ceq:0 */
|
||||
int eqn;
|
||||
u32 entries;
|
||||
int log_entries;
|
||||
u32 log_entries;
|
||||
int eqe_size;
|
||||
int irq;
|
||||
int log_page_size;
|
||||
int cons_index;
|
||||
u32 cons_index;
|
||||
struct hns_roce_buf_list *buf_list;
|
||||
int over_ignore;
|
||||
int coalesce;
|
||||
@@ -742,7 +739,7 @@ struct hns_roce_eq {
|
||||
int hop_num;
|
||||
struct hns_roce_mtr mtr;
|
||||
u16 eq_max_cnt;
|
||||
int eq_period;
|
||||
u32 eq_period;
|
||||
int shift;
|
||||
int event_type;
|
||||
int sub_type;
|
||||
@@ -765,8 +762,8 @@ struct hns_roce_caps {
|
||||
u32 max_sq_inline;
|
||||
u32 max_rq_sg;
|
||||
u32 max_extend_sg;
|
||||
int num_qps;
|
||||
int reserved_qps;
|
||||
u32 num_qps;
|
||||
u32 reserved_qps;
|
||||
int num_qpc_timer;
|
||||
int num_cqc_timer;
|
||||
int num_srqs;
|
||||
@@ -778,7 +775,7 @@ struct hns_roce_caps {
|
||||
u32 max_srq_desc_sz;
|
||||
int max_qp_init_rdma;
|
||||
int max_qp_dest_rdma;
|
||||
int num_cqs;
|
||||
u32 num_cqs;
|
||||
u32 max_cqes;
|
||||
u32 min_cqes;
|
||||
u32 min_wqes;
|
||||
@@ -787,7 +784,7 @@ struct hns_roce_caps {
|
||||
int num_aeq_vectors;
|
||||
int num_comp_vectors;
|
||||
int num_other_vectors;
|
||||
int num_mtpts;
|
||||
u32 num_mtpts;
|
||||
u32 num_mtt_segs;
|
||||
u32 num_cqe_segs;
|
||||
u32 num_srqwqe_segs;
|
||||
@@ -825,6 +822,7 @@ struct hns_roce_caps {
|
||||
u32 cqc_timer_bt_num;
|
||||
u32 mpt_bt_num;
|
||||
u32 sccc_bt_num;
|
||||
u32 gmv_bt_num;
|
||||
u32 qpc_ba_pg_sz;
|
||||
u32 qpc_buf_pg_sz;
|
||||
u32 qpc_hop_num;
|
||||
@@ -864,6 +862,11 @@ struct hns_roce_caps {
|
||||
u32 eqe_ba_pg_sz;
|
||||
u32 eqe_buf_pg_sz;
|
||||
u32 eqe_hop_num;
|
||||
u32 gmv_entry_num;
|
||||
u32 gmv_entry_sz;
|
||||
u32 gmv_ba_pg_sz;
|
||||
u32 gmv_buf_pg_sz;
|
||||
u32 gmv_hop_num;
|
||||
u32 sl_num;
|
||||
u32 tsq_buf_pg_sz;
|
||||
u32 tpq_buf_pg_sz;
|
||||
@@ -898,7 +901,7 @@ struct hns_roce_hw {
|
||||
int (*post_mbox)(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
u64 out_param, u32 in_modifier, u8 op_modifier, u16 op,
|
||||
u16 token, int event);
|
||||
int (*chk_mbox)(struct hns_roce_dev *hr_dev, unsigned long timeout);
|
||||
int (*chk_mbox)(struct hns_roce_dev *hr_dev, unsigned int timeout);
|
||||
int (*rst_prc_mbox)(struct hns_roce_dev *hr_dev);
|
||||
int (*set_gid)(struct hns_roce_dev *hr_dev, u8 port, int gid_index,
|
||||
const union ib_gid *gid, const struct ib_gid_attr *attr);
|
||||
@@ -999,6 +1002,10 @@ struct hns_roce_dev {
|
||||
struct hns_roce_eq_table eq_table;
|
||||
struct hns_roce_hem_table qpc_timer_table;
|
||||
struct hns_roce_hem_table cqc_timer_table;
|
||||
/* GMV is the memory area that the driver allocates for the hardware
|
||||
* to store SGID, SMAC and VLAN information.
|
||||
*/
|
||||
struct hns_roce_hem_table gmv_table;
|
||||
|
||||
int cmd_mod;
|
||||
int loop_idc;
|
||||
@@ -1069,29 +1076,19 @@ static inline struct hns_roce_qp
|
||||
return xa_load(&hr_dev->qp_table_xa, qpn & (hr_dev->caps.num_qps - 1));
|
||||
}
|
||||
|
||||
static inline bool hns_roce_buf_is_direct(struct hns_roce_buf *buf)
|
||||
static inline void *hns_roce_buf_offset(struct hns_roce_buf *buf,
|
||||
unsigned int offset)
|
||||
{
|
||||
if (buf->page_list)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return (char *)(buf->trunk_list[offset >> buf->trunk_shift].buf) +
|
||||
(offset & ((1 << buf->trunk_shift) - 1));
|
||||
}
|
||||
|
||||
static inline void *hns_roce_buf_offset(struct hns_roce_buf *buf, int offset)
|
||||
static inline dma_addr_t hns_roce_buf_page(struct hns_roce_buf *buf, u32 idx)
|
||||
{
|
||||
if (hns_roce_buf_is_direct(buf))
|
||||
return (char *)(buf->direct.buf) + (offset & (buf->size - 1));
|
||||
unsigned int offset = idx << buf->page_shift;
|
||||
|
||||
return (char *)(buf->page_list[offset >> buf->page_shift].buf) +
|
||||
(offset & ((1 << buf->page_shift) - 1));
|
||||
}
|
||||
|
||||
static inline dma_addr_t hns_roce_buf_page(struct hns_roce_buf *buf, int idx)
|
||||
{
|
||||
if (hns_roce_buf_is_direct(buf))
|
||||
return buf->direct.map + ((dma_addr_t)idx << buf->page_shift);
|
||||
else
|
||||
return buf->page_list[idx].map;
|
||||
return buf->trunk_list[offset >> buf->trunk_shift].map +
|
||||
(offset & ((1 << buf->trunk_shift) - 1));
|
||||
}
|
||||
|
||||
#define hr_hw_page_align(x) ALIGN(x, 1 << HNS_HW_PAGE_SHIFT)
|
||||
@@ -1132,6 +1129,14 @@ static inline u32 to_hr_hem_entries_shift(u32 count, u32 buf_shift)
|
||||
return ilog2(to_hr_hem_entries_count(count, buf_shift));
|
||||
}
|
||||
|
||||
#define DSCP_SHIFT 2
|
||||
|
||||
static inline u8 get_tclass(const struct ib_global_route *grh)
|
||||
{
|
||||
return grh->sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP ?
|
||||
grh->traffic_class >> DSCP_SHIFT : grh->traffic_class;
|
||||
}
|
||||
|
||||
int hns_roce_init_uar_table(struct hns_roce_dev *dev);
|
||||
int hns_roce_uar_alloc(struct hns_roce_dev *dev, struct hns_roce_uar *uar);
|
||||
void hns_roce_uar_free(struct hns_roce_dev *dev, struct hns_roce_uar *uar);
|
||||
@@ -1155,7 +1160,7 @@ int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
void hns_roce_mtr_destroy(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_mtr *mtr);
|
||||
int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
dma_addr_t *pages, int page_cnt);
|
||||
dma_addr_t *pages, unsigned int page_cnt);
|
||||
|
||||
int hns_roce_init_pd_table(struct hns_roce_dev *hr_dev);
|
||||
int hns_roce_init_mr_table(struct hns_roce_dev *hr_dev);
|
||||
@@ -1198,9 +1203,10 @@ struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_udata *udata);
|
||||
int hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
u32 max_num_sg);
|
||||
int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
@@ -1215,8 +1221,8 @@ int hns_roce_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
|
||||
int hns_roce_dealloc_mw(struct ib_mw *ibmw);
|
||||
|
||||
void hns_roce_buf_free(struct hns_roce_dev *hr_dev, struct hns_roce_buf *buf);
|
||||
int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
|
||||
struct hns_roce_buf *buf, u32 page_shift);
|
||||
struct hns_roce_buf *hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size,
|
||||
u32 page_shift, u32 flags);
|
||||
|
||||
int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
|
||||
int buf_cnt, int start, struct hns_roce_buf *buf);
|
||||
@@ -1238,10 +1244,10 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
|
||||
int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
int attr_mask, struct ib_udata *udata);
|
||||
void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
|
||||
void *hns_roce_get_recv_wqe(struct hns_roce_qp *hr_qp, int n);
|
||||
void *hns_roce_get_send_wqe(struct hns_roce_qp *hr_qp, int n);
|
||||
void *hns_roce_get_extend_sge(struct hns_roce_qp *hr_qp, int n);
|
||||
bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
|
||||
void *hns_roce_get_recv_wqe(struct hns_roce_qp *hr_qp, unsigned int n);
|
||||
void *hns_roce_get_send_wqe(struct hns_roce_qp *hr_qp, unsigned int n);
|
||||
void *hns_roce_get_extend_sge(struct hns_roce_qp *hr_qp, unsigned int n);
|
||||
bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, u32 nreq,
|
||||
struct ib_cq *ib_cq);
|
||||
enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state);
|
||||
void hns_roce_lock_cqs(struct hns_roce_cq *send_cq,
|
||||
@@ -1271,7 +1277,7 @@ void hns_roce_cq_completion(struct hns_roce_dev *hr_dev, u32 cqn);
|
||||
void hns_roce_cq_event(struct hns_roce_dev *hr_dev, u32 cqn, int event_type);
|
||||
void hns_roce_qp_event(struct hns_roce_dev *hr_dev, u32 qpn, int event_type);
|
||||
void hns_roce_srq_event(struct hns_roce_dev *hr_dev, u32 srqn, int event_type);
|
||||
int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index);
|
||||
u8 hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index);
|
||||
void hns_roce_handle_device_err(struct hns_roce_dev *hr_dev);
|
||||
int hns_roce_init(struct hns_roce_dev *hr_dev);
|
||||
void hns_roce_exit(struct hns_roce_dev *hr_dev);
|
||||
|
||||
@@ -75,6 +75,9 @@ bool hns_roce_check_whether_mhop(struct hns_roce_dev *hr_dev, u32 type)
|
||||
case HEM_TYPE_CQC_TIMER:
|
||||
hop_num = hr_dev->caps.cqc_timer_hop_num;
|
||||
break;
|
||||
case HEM_TYPE_GMV:
|
||||
hop_num = hr_dev->caps.gmv_hop_num;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -183,8 +186,16 @@ static int get_hem_table_config(struct hns_roce_dev *hr_dev,
|
||||
mhop->ba_l0_num = hr_dev->caps.srqc_bt_num;
|
||||
mhop->hop_num = hr_dev->caps.srqc_hop_num;
|
||||
break;
|
||||
case HEM_TYPE_GMV:
|
||||
mhop->buf_chunk_size = 1 << (hr_dev->caps.gmv_buf_pg_sz +
|
||||
PAGE_SHIFT);
|
||||
mhop->bt_chunk_size = 1 << (hr_dev->caps.gmv_ba_pg_sz +
|
||||
PAGE_SHIFT);
|
||||
mhop->ba_l0_num = hr_dev->caps.gmv_bt_num;
|
||||
mhop->hop_num = hr_dev->caps.gmv_hop_num;
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Table %d not support multi-hop addressing!\n",
|
||||
dev_err(dev, "table %u not support multi-hop addressing!\n",
|
||||
type);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -198,9 +209,9 @@ int hns_roce_calc_hem_mhop(struct hns_roce_dev *hr_dev,
|
||||
{
|
||||
struct device *dev = hr_dev->dev;
|
||||
u32 chunk_ba_num;
|
||||
u32 chunk_size;
|
||||
u32 table_idx;
|
||||
u32 bt_num;
|
||||
u32 chunk_size;
|
||||
|
||||
if (get_hem_table_config(hr_dev, mhop, table->type))
|
||||
return -EINVAL;
|
||||
@@ -232,8 +243,8 @@ int hns_roce_calc_hem_mhop(struct hns_roce_dev *hr_dev,
|
||||
mhop->l0_idx = table_idx;
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Table %d not support hop_num = %d!\n",
|
||||
table->type, mhop->hop_num);
|
||||
dev_err(dev, "table %u not support hop_num = %u!\n",
|
||||
table->type, mhop->hop_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (mhop->l0_idx >= mhop->ba_l0_num)
|
||||
@@ -332,15 +343,15 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
|
||||
{
|
||||
spinlock_t *lock = &hr_dev->bt_cmd_lock;
|
||||
struct device *dev = hr_dev->dev;
|
||||
long end;
|
||||
unsigned long flags;
|
||||
struct hns_roce_hem_iter iter;
|
||||
void __iomem *bt_cmd;
|
||||
__le32 bt_cmd_val[2];
|
||||
__le32 bt_cmd_h = 0;
|
||||
unsigned long flags;
|
||||
__le32 bt_cmd_l;
|
||||
u64 bt_ba;
|
||||
int ret = 0;
|
||||
u64 bt_ba;
|
||||
long end;
|
||||
|
||||
/* Find the HEM(Hardware Entry Memory) entry */
|
||||
unsigned long i = (obj & (table->num_obj - 1)) /
|
||||
@@ -438,13 +449,13 @@ static int calc_hem_config(struct hns_roce_dev *hr_dev,
|
||||
index->buf = l0_idx;
|
||||
break;
|
||||
default:
|
||||
ibdev_err(ibdev, "Table %d not support mhop.hop_num = %d!\n",
|
||||
ibdev_err(ibdev, "table %u not support mhop.hop_num = %u!\n",
|
||||
table->type, mhop->hop_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (unlikely(index->buf >= table->num_hem)) {
|
||||
ibdev_err(ibdev, "Table %d exceed hem limt idx %llu,max %lu!\n",
|
||||
ibdev_err(ibdev, "table %u exceed hem limt idx %llu, max %lu!\n",
|
||||
table->type, index->buf, table->num_hem);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -640,8 +651,8 @@ int hns_roce_table_get(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_hem_table *table, unsigned long obj)
|
||||
{
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret = 0;
|
||||
unsigned long i;
|
||||
int ret = 0;
|
||||
|
||||
if (hns_roce_check_whether_mhop(hr_dev, table->type))
|
||||
return hns_roce_table_mhop_get(hr_dev, table, obj);
|
||||
@@ -714,15 +725,15 @@ static void clear_mhop_hem(struct hns_roce_dev *hr_dev,
|
||||
step_idx = hop_num;
|
||||
|
||||
if (hr_dev->hw->clear_hem(hr_dev, table, obj, step_idx))
|
||||
ibdev_warn(ibdev, "Clear hop%d HEM failed.\n", hop_num);
|
||||
ibdev_warn(ibdev, "failed to clear hop%u HEM.\n", hop_num);
|
||||
|
||||
if (index->inited & HEM_INDEX_L1)
|
||||
if (hr_dev->hw->clear_hem(hr_dev, table, obj, 1))
|
||||
ibdev_warn(ibdev, "Clear HEM step 1 failed.\n");
|
||||
ibdev_warn(ibdev, "failed to clear HEM step 1.\n");
|
||||
|
||||
if (index->inited & HEM_INDEX_L0)
|
||||
if (hr_dev->hw->clear_hem(hr_dev, table, obj, 0))
|
||||
ibdev_warn(ibdev, "Clear HEM step 0 failed.\n");
|
||||
ibdev_warn(ibdev, "failed to clear HEM step 0.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,14 +800,14 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_hem_chunk *chunk;
|
||||
struct hns_roce_hem_mhop mhop;
|
||||
struct hns_roce_hem *hem;
|
||||
void *addr = NULL;
|
||||
unsigned long mhop_obj = obj;
|
||||
unsigned long obj_per_chunk;
|
||||
unsigned long idx_offset;
|
||||
int offset, dma_offset;
|
||||
void *addr = NULL;
|
||||
u32 hem_idx = 0;
|
||||
int length;
|
||||
int i, j;
|
||||
u32 hem_idx = 0;
|
||||
|
||||
if (!table->lowmem)
|
||||
return NULL;
|
||||
@@ -876,7 +887,7 @@ int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
|
||||
unsigned long buf_chunk_size;
|
||||
unsigned long bt_chunk_size;
|
||||
unsigned long bt_chunk_num;
|
||||
unsigned long num_bt_l0 = 0;
|
||||
unsigned long num_bt_l0;
|
||||
u32 hop_num;
|
||||
|
||||
if (get_hem_table_config(hr_dev, &mhop, type))
|
||||
@@ -966,8 +977,8 @@ static void hns_roce_cleanup_mhop_hem_table(struct hns_roce_dev *hr_dev,
|
||||
{
|
||||
struct hns_roce_hem_mhop mhop;
|
||||
u32 buf_chunk_size;
|
||||
int i;
|
||||
u64 obj;
|
||||
int i;
|
||||
|
||||
if (hns_roce_calc_hem_mhop(hr_dev, table, NULL, &mhop))
|
||||
return;
|
||||
@@ -1017,7 +1028,7 @@ void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,
|
||||
|
||||
void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
if (hr_dev->caps.srqc_entry_sz)
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ)
|
||||
hns_roce_cleanup_hem_table(hr_dev,
|
||||
&hr_dev->srq_table.table);
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->cq_table.table);
|
||||
@@ -1027,12 +1038,16 @@ void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev)
|
||||
if (hr_dev->caps.cqc_timer_entry_sz)
|
||||
hns_roce_cleanup_hem_table(hr_dev,
|
||||
&hr_dev->cqc_timer_table);
|
||||
if (hr_dev->caps.sccc_sz)
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL)
|
||||
hns_roce_cleanup_hem_table(hr_dev,
|
||||
&hr_dev->qp_table.sccc_table);
|
||||
if (hr_dev->caps.trrl_entry_sz)
|
||||
hns_roce_cleanup_hem_table(hr_dev,
|
||||
&hr_dev->qp_table.trrl_table);
|
||||
|
||||
if (hr_dev->caps.gmv_entry_sz)
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->gmv_table);
|
||||
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.irrl_table);
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.qp_table);
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table);
|
||||
@@ -1234,7 +1249,7 @@ static int hem_list_alloc_mid_bt(struct hns_roce_dev *hr_dev,
|
||||
}
|
||||
|
||||
if (offset < r->offset) {
|
||||
dev_err(hr_dev->dev, "invalid offset %d,min %d!\n",
|
||||
dev_err(hr_dev->dev, "invalid offset %d, min %u!\n",
|
||||
offset, r->offset);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1298,8 +1313,8 @@ static int hem_list_alloc_root_bt(struct hns_roce_dev *hr_dev,
|
||||
const struct hns_roce_buf_region *regions,
|
||||
int region_cnt)
|
||||
{
|
||||
struct roce_hem_item *hem, *temp_hem, *root_hem;
|
||||
struct list_head temp_list[HNS_ROCE_MAX_BT_REGION];
|
||||
struct roce_hem_item *hem, *temp_hem, *root_hem;
|
||||
const struct hns_roce_buf_region *r;
|
||||
struct list_head temp_root;
|
||||
struct list_head temp_btm;
|
||||
@@ -1404,8 +1419,8 @@ int hns_roce_hem_list_request(struct hns_roce_dev *hr_dev,
|
||||
{
|
||||
const struct hns_roce_buf_region *r;
|
||||
int ofs, end;
|
||||
int ret;
|
||||
int unit;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
if (region_cnt > HNS_ROCE_MAX_BT_REGION) {
|
||||
|
||||
@@ -47,6 +47,7 @@ enum {
|
||||
HEM_TYPE_SCCC,
|
||||
HEM_TYPE_QPC_TIMER,
|
||||
HEM_TYPE_CQC_TIMER,
|
||||
HEM_TYPE_GMV,
|
||||
|
||||
/* UNMAP HEM */
|
||||
HEM_TYPE_MTT,
|
||||
@@ -174,4 +175,4 @@ static inline dma_addr_t hns_roce_hem_addr(struct hns_roce_hem_iter *iter)
|
||||
return sg_dma_address(&iter->chunk->mem[iter->page_idx]);
|
||||
}
|
||||
|
||||
#endif /*_HNS_ROCE_HEM_H*/
|
||||
#endif /* _HNS_ROCE_HEM_H */
|
||||
|
||||
@@ -239,7 +239,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
|
||||
break;
|
||||
}
|
||||
|
||||
/*Ctrl field, ctrl set type: sig, solic, imm, fence */
|
||||
/* Ctrl field, ctrl set type: sig, solic, imm, fence */
|
||||
/* SO wait for conforming application scenarios */
|
||||
ctrl->flag |= (wr->send_flags & IB_SEND_SIGNALED ?
|
||||
cpu_to_le32(HNS_ROCE_WQE_CQ_NOTIFY) : 0) |
|
||||
@@ -288,7 +288,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
|
||||
ret = -EINVAL;
|
||||
*bad_wr = wr;
|
||||
dev_err(dev, "inline len(1-%d)=%d, illegal",
|
||||
ctrl->msg_length,
|
||||
le32_to_cpu(ctrl->msg_length),
|
||||
hr_dev->caps.max_sq_inline);
|
||||
goto out;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
|
||||
}
|
||||
ctrl->flag |= cpu_to_le32(HNS_ROCE_WQE_INLINE);
|
||||
} else {
|
||||
/*sqe num is two */
|
||||
/* sqe num is two */
|
||||
for (i = 0; i < wr->num_sge; i++)
|
||||
set_data_seg(dseg + i, wr->sg_list + i);
|
||||
|
||||
@@ -353,8 +353,8 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
|
||||
unsigned long flags = 0;
|
||||
unsigned int wqe_idx;
|
||||
int ret = 0;
|
||||
int nreq = 0;
|
||||
int i = 0;
|
||||
int nreq;
|
||||
int i;
|
||||
u32 reg_val;
|
||||
|
||||
spin_lock_irqsave(&hr_qp->rq.lock, flags);
|
||||
@@ -1165,7 +1165,7 @@ static int hns_roce_raq_init(struct hns_roce_dev *hr_dev)
|
||||
}
|
||||
raq->e_raq_buf->map = addr;
|
||||
|
||||
/* Configure raq extended address. 48bit 4K align*/
|
||||
/* Configure raq extended address. 48bit 4K align */
|
||||
roce_write(hr_dev, ROCEE_EXT_RAQ_REG, raq->e_raq_buf->map >> 12);
|
||||
|
||||
/* Configure raq_shift */
|
||||
@@ -1639,7 +1639,7 @@ static int hns_roce_v1_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param,
|
||||
}
|
||||
|
||||
static int hns_roce_v1_chk_mbox(struct hns_roce_dev *hr_dev,
|
||||
unsigned long timeout)
|
||||
unsigned int timeout)
|
||||
{
|
||||
u8 __iomem *hcr = hr_dev->reg_base + ROCEE_MB1_REG;
|
||||
unsigned long end;
|
||||
@@ -2062,11 +2062,6 @@ static void hns_roce_v1_write_cqc(struct hns_roce_dev *hr_dev,
|
||||
CQ_CONTEXT_CQC_BYTE_32_CQ_CONS_IDX_S, 0);
|
||||
}
|
||||
|
||||
static int hns_roce_v1_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int hns_roce_v1_req_notify_cq(struct ib_cq *ibcq,
|
||||
enum ib_cq_notify_flags flags)
|
||||
{
|
||||
@@ -2305,7 +2300,7 @@ int hns_roce_v1_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
|
||||
struct hns_roce_qp *cur_qp = NULL;
|
||||
unsigned long flags;
|
||||
int npolled;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
spin_lock_irqsave(&hr_cq->lock, flags);
|
||||
|
||||
@@ -2765,7 +2760,6 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
|
||||
roce_set_field(context->qpc_bytes_16,
|
||||
QP_CONTEXT_QPC_BYTES_16_QP_NUM_M,
|
||||
QP_CONTEXT_QPC_BYTES_16_QP_NUM_S, hr_qp->qpn);
|
||||
|
||||
} else if (cur_state == IB_QPS_INIT && new_state == IB_QPS_INIT) {
|
||||
roce_set_field(context->qpc_bytes_4,
|
||||
QP_CONTEXT_QPC_BYTES_4_TRANSPORT_SERVICE_TYPE_M,
|
||||
@@ -3261,6 +3255,8 @@ static int hns_roce_v1_modify_qp(struct ib_qp *ibqp,
|
||||
enum ib_qp_state cur_state,
|
||||
enum ib_qp_state new_state)
|
||||
{
|
||||
if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI)
|
||||
return hns_roce_v1_m_sqp(ibqp, attr, attr_mask, cur_state,
|
||||
@@ -3604,10 +3600,10 @@ static int hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_eq_cons_index_v1(struct hns_roce_eq *eq, int req_not)
|
||||
static void set_eq_cons_index_v1(struct hns_roce_eq *eq, u32 req_not)
|
||||
{
|
||||
roce_raw_write((eq->cons_index & HNS_ROCE_V1_CONS_IDX_M) |
|
||||
(req_not << eq->log_entries), eq->doorbell);
|
||||
(req_not << eq->log_entries), eq->doorbell);
|
||||
}
|
||||
|
||||
static void hns_roce_v1_wq_catas_err_handle(struct hns_roce_dev *hr_dev,
|
||||
@@ -3687,10 +3683,10 @@ static void hns_roce_v1_qp_err_handle(struct hns_roce_dev *hr_dev,
|
||||
int phy_port;
|
||||
int qpn;
|
||||
|
||||
qpn = roce_get_field(aeqe->event.qp_event.qp,
|
||||
qpn = roce_get_field(aeqe->event.queue_event.num,
|
||||
HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
|
||||
HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S);
|
||||
phy_port = roce_get_field(aeqe->event.qp_event.qp,
|
||||
phy_port = roce_get_field(aeqe->event.queue_event.num,
|
||||
HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_M,
|
||||
HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_S);
|
||||
if (qpn <= 1)
|
||||
@@ -3721,9 +3717,9 @@ static void hns_roce_v1_cq_err_handle(struct hns_roce_dev *hr_dev,
|
||||
struct device *dev = &hr_dev->pdev->dev;
|
||||
u32 cqn;
|
||||
|
||||
cqn = roce_get_field(aeqe->event.cq_event.cq,
|
||||
HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
|
||||
HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S);
|
||||
cqn = roce_get_field(aeqe->event.queue_event.num,
|
||||
HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
|
||||
HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S);
|
||||
|
||||
switch (event_type) {
|
||||
case HNS_ROCE_EVENT_TYPE_CQ_ACCESS_ERROR:
|
||||
@@ -3798,7 +3794,6 @@ static int hns_roce_v1_aeq_int(struct hns_roce_dev *hr_dev,
|
||||
int event_type;
|
||||
|
||||
while ((aeqe = next_aeqe_sw_v1(eq))) {
|
||||
|
||||
/* Make sure we read the AEQ entry after we have checked the
|
||||
* ownership bit
|
||||
*/
|
||||
@@ -3853,12 +3848,6 @@ static int hns_roce_v1_aeq_int(struct hns_roce_dev *hr_dev,
|
||||
case HNS_ROCE_EVENT_TYPE_DB_OVERFLOW:
|
||||
hns_roce_v1_db_overflow_handle(hr_dev, aeqe);
|
||||
break;
|
||||
case HNS_ROCE_EVENT_TYPE_CEQ_OVERFLOW:
|
||||
dev_warn(dev, "CEQ 0x%lx overflow.\n",
|
||||
roce_get_field(aeqe->event.ce_event.ceqe,
|
||||
HNS_ROCE_AEQE_EVENT_CE_EVENT_CEQE_CEQN_M,
|
||||
HNS_ROCE_AEQE_EVENT_CE_EVENT_CEQE_CEQN_S));
|
||||
break;
|
||||
default:
|
||||
dev_warn(dev, "Unhandled event %d on EQ %d at idx %u.\n",
|
||||
event_type, eq->eqn, eq->cons_index);
|
||||
@@ -3903,7 +3892,6 @@ static int hns_roce_v1_ceq_int(struct hns_roce_dev *hr_dev,
|
||||
u32 cqn;
|
||||
|
||||
while ((ceqe = next_ceqe_sw_v1(eq))) {
|
||||
|
||||
/* Make sure we read CEQ entry after we have checked the
|
||||
* ownership bit
|
||||
*/
|
||||
@@ -4129,7 +4117,7 @@ static int hns_roce_v1_create_eq(struct hns_roce_dev *hr_dev,
|
||||
void __iomem *eqc = hr_dev->eq_table.eqc_base[eq->eqn];
|
||||
struct device *dev = &hr_dev->pdev->dev;
|
||||
dma_addr_t tmp_dma_addr;
|
||||
u32 eqcuridx_val = 0;
|
||||
u32 eqcuridx_val;
|
||||
u32 eqconsindx_val;
|
||||
u32 eqshift_val;
|
||||
__le32 tmp2 = 0;
|
||||
@@ -4347,7 +4335,6 @@ static void hns_roce_v1_cleanup_eq_table(struct hns_roce_dev *hr_dev)
|
||||
|
||||
static const struct ib_device_ops hns_roce_v1_dev_ops = {
|
||||
.destroy_qp = hns_roce_v1_destroy_qp,
|
||||
.modify_cq = hns_roce_v1_modify_cq,
|
||||
.poll_cq = hns_roce_v1_poll_cq,
|
||||
.post_recv = hns_roce_v1_post_recv,
|
||||
.post_send = hns_roce_v1_post_send,
|
||||
@@ -4367,7 +4354,6 @@ static const struct hns_roce_hw hns_roce_hw_v1 = {
|
||||
.set_mtu = hns_roce_v1_set_mtu,
|
||||
.write_mtpt = hns_roce_v1_write_mtpt,
|
||||
.write_cqc = hns_roce_v1_write_cqc,
|
||||
.modify_cq = hns_roce_v1_modify_cq,
|
||||
.clear_hem = hns_roce_v1_clear_hem,
|
||||
.modify_qp = hns_roce_v1_modify_qp,
|
||||
.query_qp = hns_roce_v1_query_qp,
|
||||
|
||||
@@ -419,7 +419,7 @@ struct hns_roce_wqe_data_seg {
|
||||
|
||||
struct hns_roce_wqe_raddr_seg {
|
||||
__le32 rkey;
|
||||
__le32 len;/* reserved */
|
||||
__le32 len; /* reserved */
|
||||
__le64 raddr;
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,7 @@
|
||||
#define HNS_ROCE_VF_SMAC_NUM 32
|
||||
#define HNS_ROCE_VF_SGID_NUM 32
|
||||
#define HNS_ROCE_VF_SL_NUM 8
|
||||
#define HNS_ROCE_VF_GMV_BT_NUM 256
|
||||
|
||||
#define HNS_ROCE_V2_MAX_QP_NUM 0x100000
|
||||
#define HNS_ROCE_V2_MAX_QPC_TIMER_NUM 0x200
|
||||
@@ -89,6 +90,7 @@
|
||||
|
||||
#define HNS_ROCE_V2_SCCC_SZ 32
|
||||
#define HNS_ROCE_V3_SCCC_SZ 64
|
||||
#define HNS_ROCE_V3_GMV_ENTRY_SZ 32
|
||||
|
||||
#define HNS_ROCE_V2_QPC_TIMER_ENTRY_SZ PAGE_SIZE
|
||||
#define HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ PAGE_SIZE
|
||||
@@ -241,6 +243,8 @@ enum hns_roce_opcode_type {
|
||||
HNS_ROCE_OPC_CLR_SCCC = 0x8509,
|
||||
HNS_ROCE_OPC_QUERY_SCCC = 0x850a,
|
||||
HNS_ROCE_OPC_RESET_SCCC = 0x850b,
|
||||
HNS_ROCE_OPC_CFG_GMV_TBL = 0x850f,
|
||||
HNS_ROCE_OPC_CFG_GMV_BT = 0x8510,
|
||||
HNS_SWITCH_PARAMETER_CFG = 0x1033,
|
||||
};
|
||||
|
||||
@@ -263,23 +267,24 @@ enum hns_roce_sgid_type {
|
||||
};
|
||||
|
||||
struct hns_roce_v2_cq_context {
|
||||
__le32 byte_4_pg_ceqn;
|
||||
__le32 byte_8_cqn;
|
||||
__le32 cqe_cur_blk_addr;
|
||||
__le32 byte_16_hop_addr;
|
||||
__le32 cqe_nxt_blk_addr;
|
||||
__le32 byte_24_pgsz_addr;
|
||||
__le32 byte_28_cq_pi;
|
||||
__le32 byte_32_cq_ci;
|
||||
__le32 cqe_ba;
|
||||
__le32 byte_40_cqe_ba;
|
||||
__le32 byte_44_db_record;
|
||||
__le32 db_record_addr;
|
||||
__le32 byte_52_cqe_cnt;
|
||||
__le32 byte_56_cqe_period_maxcnt;
|
||||
__le32 cqe_report_timer;
|
||||
__le32 byte_64_se_cqe_idx;
|
||||
__le32 byte_4_pg_ceqn;
|
||||
__le32 byte_8_cqn;
|
||||
__le32 cqe_cur_blk_addr;
|
||||
__le32 byte_16_hop_addr;
|
||||
__le32 cqe_nxt_blk_addr;
|
||||
__le32 byte_24_pgsz_addr;
|
||||
__le32 byte_28_cq_pi;
|
||||
__le32 byte_32_cq_ci;
|
||||
__le32 cqe_ba;
|
||||
__le32 byte_40_cqe_ba;
|
||||
__le32 byte_44_db_record;
|
||||
__le32 db_record_addr;
|
||||
__le32 byte_52_cqe_cnt;
|
||||
__le32 byte_56_cqe_period_maxcnt;
|
||||
__le32 cqe_report_timer;
|
||||
__le32 byte_64_se_cqe_idx;
|
||||
};
|
||||
|
||||
#define HNS_ROCE_V2_CQ_DEFAULT_BURST_NUM 0x0
|
||||
#define HNS_ROCE_V2_CQ_DEFAULT_INTERVAL 0x0
|
||||
|
||||
@@ -356,6 +361,10 @@ struct hns_roce_v2_cq_context {
|
||||
#define V2_CQC_BYTE_64_SE_CQE_IDX_S 0
|
||||
#define V2_CQC_BYTE_64_SE_CQE_IDX_M GENMASK(23, 0)
|
||||
|
||||
#define CQC_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_v2_cq_context, h, l)
|
||||
|
||||
#define CQC_STASH CQC_FIELD_LOC(63, 63)
|
||||
|
||||
struct hns_roce_srq_context {
|
||||
__le32 byte_4_srqn_srqst;
|
||||
__le32 byte_8_limit_wl;
|
||||
@@ -440,7 +449,7 @@ struct hns_roce_srq_context {
|
||||
#define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_S 1
|
||||
#define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_M GENMASK(31, 1)
|
||||
|
||||
enum{
|
||||
enum {
|
||||
V2_MPT_ST_VALID = 0x1,
|
||||
V2_MPT_ST_FREE = 0x2,
|
||||
};
|
||||
@@ -457,68 +466,72 @@ enum hns_roce_v2_qp_state {
|
||||
HNS_ROCE_QP_NUM_ST
|
||||
};
|
||||
|
||||
struct hns_roce_v2_qp_context_ex {
|
||||
__le32 data[64];
|
||||
};
|
||||
struct hns_roce_v2_qp_context {
|
||||
__le32 byte_4_sqpn_tst;
|
||||
__le32 wqe_sge_ba;
|
||||
__le32 byte_12_sq_hop;
|
||||
__le32 byte_16_buf_ba_pg_sz;
|
||||
__le32 byte_20_smac_sgid_idx;
|
||||
__le32 byte_24_mtu_tc;
|
||||
__le32 byte_28_at_fl;
|
||||
u8 dgid[GID_LEN_V2];
|
||||
__le32 dmac;
|
||||
__le32 byte_52_udpspn_dmac;
|
||||
__le32 byte_56_dqpn_err;
|
||||
__le32 byte_60_qpst_tempid;
|
||||
__le32 qkey_xrcd;
|
||||
__le32 byte_68_rq_db;
|
||||
__le32 rq_db_record_addr;
|
||||
__le32 byte_76_srqn_op_en;
|
||||
__le32 byte_80_rnr_rx_cqn;
|
||||
__le32 byte_84_rq_ci_pi;
|
||||
__le32 rq_cur_blk_addr;
|
||||
__le32 byte_92_srq_info;
|
||||
__le32 byte_96_rx_reqmsn;
|
||||
__le32 rq_nxt_blk_addr;
|
||||
__le32 byte_104_rq_sge;
|
||||
__le32 byte_108_rx_reqepsn;
|
||||
__le32 rq_rnr_timer;
|
||||
__le32 rx_msg_len;
|
||||
__le32 rx_rkey_pkt_info;
|
||||
__le64 rx_va;
|
||||
__le32 byte_132_trrl;
|
||||
__le32 trrl_ba;
|
||||
__le32 byte_140_raq;
|
||||
__le32 byte_144_raq;
|
||||
__le32 byte_148_raq;
|
||||
__le32 byte_152_raq;
|
||||
__le32 byte_156_raq;
|
||||
__le32 byte_160_sq_ci_pi;
|
||||
__le32 sq_cur_blk_addr;
|
||||
__le32 byte_168_irrl_idx;
|
||||
__le32 byte_172_sq_psn;
|
||||
__le32 byte_176_msg_pktn;
|
||||
__le32 sq_cur_sge_blk_addr;
|
||||
__le32 byte_184_irrl_idx;
|
||||
__le32 cur_sge_offset;
|
||||
__le32 byte_192_ext_sge;
|
||||
__le32 byte_196_sq_psn;
|
||||
__le32 byte_200_sq_max;
|
||||
__le32 irrl_ba;
|
||||
__le32 byte_208_irrl;
|
||||
__le32 byte_212_lsn;
|
||||
__le32 sq_timer;
|
||||
__le32 byte_220_retry_psn_msn;
|
||||
__le32 byte_224_retry_msg;
|
||||
__le32 rx_sq_cur_blk_addr;
|
||||
__le32 byte_232_irrl_sge;
|
||||
__le32 irrl_cur_sge_offset;
|
||||
__le32 byte_240_irrl_tail;
|
||||
__le32 byte_244_rnr_rxack;
|
||||
__le32 byte_248_ack_psn;
|
||||
__le32 byte_252_err_txcqn;
|
||||
__le32 byte_256_sqflush_rqcqe;
|
||||
__le32 ext[64];
|
||||
__le32 byte_4_sqpn_tst;
|
||||
__le32 wqe_sge_ba;
|
||||
__le32 byte_12_sq_hop;
|
||||
__le32 byte_16_buf_ba_pg_sz;
|
||||
__le32 byte_20_smac_sgid_idx;
|
||||
__le32 byte_24_mtu_tc;
|
||||
__le32 byte_28_at_fl;
|
||||
u8 dgid[GID_LEN_V2];
|
||||
__le32 dmac;
|
||||
__le32 byte_52_udpspn_dmac;
|
||||
__le32 byte_56_dqpn_err;
|
||||
__le32 byte_60_qpst_tempid;
|
||||
__le32 qkey_xrcd;
|
||||
__le32 byte_68_rq_db;
|
||||
__le32 rq_db_record_addr;
|
||||
__le32 byte_76_srqn_op_en;
|
||||
__le32 byte_80_rnr_rx_cqn;
|
||||
__le32 byte_84_rq_ci_pi;
|
||||
__le32 rq_cur_blk_addr;
|
||||
__le32 byte_92_srq_info;
|
||||
__le32 byte_96_rx_reqmsn;
|
||||
__le32 rq_nxt_blk_addr;
|
||||
__le32 byte_104_rq_sge;
|
||||
__le32 byte_108_rx_reqepsn;
|
||||
__le32 rq_rnr_timer;
|
||||
__le32 rx_msg_len;
|
||||
__le32 rx_rkey_pkt_info;
|
||||
__le64 rx_va;
|
||||
__le32 byte_132_trrl;
|
||||
__le32 trrl_ba;
|
||||
__le32 byte_140_raq;
|
||||
__le32 byte_144_raq;
|
||||
__le32 byte_148_raq;
|
||||
__le32 byte_152_raq;
|
||||
__le32 byte_156_raq;
|
||||
__le32 byte_160_sq_ci_pi;
|
||||
__le32 sq_cur_blk_addr;
|
||||
__le32 byte_168_irrl_idx;
|
||||
__le32 byte_172_sq_psn;
|
||||
__le32 byte_176_msg_pktn;
|
||||
__le32 sq_cur_sge_blk_addr;
|
||||
__le32 byte_184_irrl_idx;
|
||||
__le32 cur_sge_offset;
|
||||
__le32 byte_192_ext_sge;
|
||||
__le32 byte_196_sq_psn;
|
||||
__le32 byte_200_sq_max;
|
||||
__le32 irrl_ba;
|
||||
__le32 byte_208_irrl;
|
||||
__le32 byte_212_lsn;
|
||||
__le32 sq_timer;
|
||||
__le32 byte_220_retry_psn_msn;
|
||||
__le32 byte_224_retry_msg;
|
||||
__le32 rx_sq_cur_blk_addr;
|
||||
__le32 byte_232_irrl_sge;
|
||||
__le32 irrl_cur_sge_offset;
|
||||
__le32 byte_240_irrl_tail;
|
||||
__le32 byte_244_rnr_rxack;
|
||||
__le32 byte_248_ack_psn;
|
||||
__le32 byte_252_err_txcqn;
|
||||
__le32 byte_256_sqflush_rqcqe;
|
||||
|
||||
struct hns_roce_v2_qp_context_ex ext;
|
||||
};
|
||||
|
||||
#define V2_QPC_BYTE_4_TST_S 0
|
||||
@@ -887,6 +900,10 @@ struct hns_roce_v2_qp_context {
|
||||
#define V2_QPC_BYTE_256_SQ_FLUSH_IDX_S 16
|
||||
#define V2_QPC_BYTE_256_SQ_FLUSH_IDX_M GENMASK(31, 16)
|
||||
|
||||
#define QPCEX_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_v2_qp_context_ex, h, l)
|
||||
|
||||
#define QPCEX_STASH QPCEX_FIELD_LOC(82, 82)
|
||||
|
||||
#define V2_QP_RWE_S 1 /* rdma write enable */
|
||||
#define V2_QP_RRE_S 2 /* rdma read enable */
|
||||
#define V2_QP_ATE_S 3 /* rdma atomic enable */
|
||||
@@ -1073,12 +1090,13 @@ struct hns_roce_v2_ud_send_wqe {
|
||||
__le32 byte_32;
|
||||
__le32 byte_36;
|
||||
__le32 byte_40;
|
||||
__le32 dmac;
|
||||
__le32 byte_48;
|
||||
u8 dmac[ETH_ALEN];
|
||||
u8 sgid_index;
|
||||
u8 smac_index;
|
||||
u8 dgid[GID_LEN_V2];
|
||||
|
||||
};
|
||||
#define V2_UD_SEND_WQE_BYTE_4_OPCODE_S 0
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_4_OPCODE_S 0
|
||||
#define V2_UD_SEND_WQE_BYTE_4_OPCODE_M GENMASK(4, 0)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_4_OWNER_S 7
|
||||
@@ -1117,37 +1135,10 @@ struct hns_roce_v2_ud_send_wqe {
|
||||
#define V2_UD_SEND_WQE_BYTE_40_SL_S 20
|
||||
#define V2_UD_SEND_WQE_BYTE_40_SL_M GENMASK(23, 20)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_40_PORTN_S 24
|
||||
#define V2_UD_SEND_WQE_BYTE_40_PORTN_M GENMASK(26, 24)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_40_UD_VLAN_EN_S 30
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_40_LBI_S 31
|
||||
|
||||
#define V2_UD_SEND_WQE_DMAC_0_S 0
|
||||
#define V2_UD_SEND_WQE_DMAC_0_M GENMASK(7, 0)
|
||||
|
||||
#define V2_UD_SEND_WQE_DMAC_1_S 8
|
||||
#define V2_UD_SEND_WQE_DMAC_1_M GENMASK(15, 8)
|
||||
|
||||
#define V2_UD_SEND_WQE_DMAC_2_S 16
|
||||
#define V2_UD_SEND_WQE_DMAC_2_M GENMASK(23, 16)
|
||||
|
||||
#define V2_UD_SEND_WQE_DMAC_3_S 24
|
||||
#define V2_UD_SEND_WQE_DMAC_3_M GENMASK(31, 24)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_48_DMAC_4_S 0
|
||||
#define V2_UD_SEND_WQE_BYTE_48_DMAC_4_M GENMASK(7, 0)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_48_DMAC_5_S 8
|
||||
#define V2_UD_SEND_WQE_BYTE_48_DMAC_5_M GENMASK(15, 8)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_48_SGID_INDX_S 16
|
||||
#define V2_UD_SEND_WQE_BYTE_48_SGID_INDX_M GENMASK(23, 16)
|
||||
|
||||
#define V2_UD_SEND_WQE_BYTE_48_SMAC_INDX_S 24
|
||||
#define V2_UD_SEND_WQE_BYTE_48_SMAC_INDX_M GENMASK(31, 24)
|
||||
|
||||
struct hns_roce_v2_rc_send_wqe {
|
||||
__le32 byte_4;
|
||||
__le32 msg_len;
|
||||
@@ -1334,7 +1325,7 @@ struct hns_roce_pf_res_b {
|
||||
__le32 sgid_idx_num;
|
||||
__le32 qid_idx_sl_num;
|
||||
__le32 sccc_bt_idx_num;
|
||||
__le32 rsv;
|
||||
__le32 gmv_idx_num;
|
||||
};
|
||||
|
||||
#define PF_RES_DATA_1_PF_SMAC_IDX_S 0
|
||||
@@ -1361,6 +1352,12 @@ struct hns_roce_pf_res_b {
|
||||
#define PF_RES_DATA_4_PF_SCCC_BT_NUM_S 9
|
||||
#define PF_RES_DATA_4_PF_SCCC_BT_NUM_M GENMASK(17, 9)
|
||||
|
||||
#define PF_RES_DATA_5_PF_GMV_BT_IDX_S 0
|
||||
#define PF_RES_DATA_5_PF_GMV_BT_IDX_M GENMASK(7, 0)
|
||||
|
||||
#define PF_RES_DATA_5_PF_GMV_BT_NUM_S 8
|
||||
#define PF_RES_DATA_5_PF_GMV_BT_NUM_M GENMASK(16, 8)
|
||||
|
||||
struct hns_roce_pf_timer_res_a {
|
||||
__le32 rsv0;
|
||||
__le32 qpc_timer_bt_idx_num;
|
||||
@@ -1425,7 +1422,7 @@ struct hns_roce_vf_res_b {
|
||||
__le32 vf_sgid_idx_num;
|
||||
__le32 vf_qid_idx_sl_num;
|
||||
__le32 vf_sccc_idx_num;
|
||||
__le32 rsv1;
|
||||
__le32 vf_gmv_idx_num;
|
||||
};
|
||||
|
||||
#define VF_RES_B_DATA_0_VF_ID_S 0
|
||||
@@ -1455,6 +1452,12 @@ struct hns_roce_vf_res_b {
|
||||
#define VF_RES_B_DATA_4_VF_SCCC_BT_NUM_S 9
|
||||
#define VF_RES_B_DATA_4_VF_SCCC_BT_NUM_M GENMASK(17, 9)
|
||||
|
||||
#define VF_RES_B_DATA_5_VF_GMV_BT_IDX_S 0
|
||||
#define VF_RES_B_DATA_5_VF_GMV_BT_IDX_M GENMASK(7, 0)
|
||||
|
||||
#define VF_RES_B_DATA_5_VF_GMV_BT_NUM_S 16
|
||||
#define VF_RES_B_DATA_5_VF_GMV_BT_NUM_M GENMASK(24, 16)
|
||||
|
||||
struct hns_roce_vf_switch {
|
||||
__le32 rocee_sel;
|
||||
__le32 fun_id;
|
||||
@@ -1577,6 +1580,46 @@ struct hns_roce_cfg_smac_tb {
|
||||
#define CFG_SMAC_TB_VF_SMAC_H_S 0
|
||||
#define CFG_SMAC_TB_VF_SMAC_H_M GENMASK(15, 0)
|
||||
|
||||
struct hns_roce_cfg_gmv_bt {
|
||||
__le32 gmv_ba_l;
|
||||
__le32 gmv_ba_h;
|
||||
__le32 gmv_bt_idx;
|
||||
__le32 rsv[3];
|
||||
};
|
||||
|
||||
#define CFG_GMV_BA_H_S 0
|
||||
#define CFG_GMV_BA_H_M GENMASK(19, 0)
|
||||
|
||||
struct hns_roce_cfg_gmv_tb_a {
|
||||
__le32 vf_sgid_l;
|
||||
__le32 vf_sgid_ml;
|
||||
__le32 vf_sgid_mh;
|
||||
__le32 vf_sgid_h;
|
||||
__le32 vf_sgid_type_vlan;
|
||||
__le32 resv;
|
||||
};
|
||||
|
||||
#define CFG_GMV_TB_SGID_IDX_S 0
|
||||
#define CFG_GMV_TB_SGID_IDX_M GENMASK(7, 0)
|
||||
|
||||
#define CFG_GMV_TB_VF_SGID_TYPE_S 0
|
||||
#define CFG_GMV_TB_VF_SGID_TYPE_M GENMASK(1, 0)
|
||||
|
||||
#define CFG_GMV_TB_VF_VLAN_EN_S 2
|
||||
|
||||
#define CFG_GMV_TB_VF_VLAN_ID_S 16
|
||||
#define CFG_GMV_TB_VF_VLAN_ID_M GENMASK(27, 16)
|
||||
|
||||
struct hns_roce_cfg_gmv_tb_b {
|
||||
__le32 vf_smac_l;
|
||||
__le32 vf_smac_h;
|
||||
__le32 table_idx_rsv;
|
||||
__le32 resv[3];
|
||||
};
|
||||
|
||||
#define CFG_GMV_TB_SMAC_H_S 0
|
||||
#define CFG_GMV_TB_SMAC_H_M GENMASK(15, 0)
|
||||
|
||||
#define HNS_ROCE_QUERY_PF_CAPS_CMD_NUM 5
|
||||
struct hns_roce_query_pf_caps_a {
|
||||
u8 number_ports;
|
||||
|
||||
@@ -33,13 +33,13 @@
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
#include <rdma/ib_cache.h>
|
||||
#include "hns_roce_common.h"
|
||||
#include "hns_roce_device.h"
|
||||
#include <rdma/hns-abi.h>
|
||||
#include "hns_roce_hem.h"
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@
|
||||
* GID[0][0], GID[1][0],.....GID[N - 1][0],
|
||||
* And so on
|
||||
*/
|
||||
int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
|
||||
u8 hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
|
||||
{
|
||||
return gid_index * hr_dev->caps.num_ports + port;
|
||||
}
|
||||
@@ -61,7 +61,10 @@ int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
|
||||
static int hns_roce_set_mac(struct hns_roce_dev *hr_dev, u8 port, u8 *addr)
|
||||
{
|
||||
u8 phy_port;
|
||||
u32 i = 0;
|
||||
u32 i;
|
||||
|
||||
if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09)
|
||||
return 0;
|
||||
|
||||
if (!memcmp(hr_dev->dev_addr[port], addr, ETH_ALEN))
|
||||
return 0;
|
||||
@@ -90,14 +93,13 @@ static int hns_roce_add_gid(const struct ib_gid_attr *attr, void **context)
|
||||
static int hns_roce_del_gid(const struct ib_gid_attr *attr, void **context)
|
||||
{
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(attr->device);
|
||||
struct ib_gid_attr zattr = {};
|
||||
u8 port = attr->port_num - 1;
|
||||
int ret;
|
||||
|
||||
if (port >= hr_dev->caps.num_ports)
|
||||
return -EINVAL;
|
||||
|
||||
ret = hr_dev->hw->set_gid(hr_dev, port, attr->index, &zgid, &zattr);
|
||||
ret = hr_dev->hw->set_gid(hr_dev, port, attr->index, NULL, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -325,7 +327,8 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx,
|
||||
|
||||
resp.cqe_size = hr_dev->caps.cqe_sz;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
ret = ib_copy_to_udata(udata, &resp,
|
||||
min(udata->outlen, sizeof(resp)));
|
||||
if (ret)
|
||||
goto error_fail_copy_to_udata;
|
||||
|
||||
@@ -421,6 +424,7 @@ static const struct ib_device_ops hns_roce_dev_ops = {
|
||||
.alloc_pd = hns_roce_alloc_pd,
|
||||
.alloc_ucontext = hns_roce_alloc_ucontext,
|
||||
.create_ah = hns_roce_create_ah,
|
||||
.create_user_ah = hns_roce_create_ah,
|
||||
.create_cq = hns_roce_create_cq,
|
||||
.create_qp = hns_roce_create_qp,
|
||||
.dealloc_pd = hns_roce_dealloc_pd,
|
||||
@@ -491,36 +495,13 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
||||
ib_dev->phys_port_cnt = hr_dev->caps.num_ports;
|
||||
ib_dev->local_dma_lkey = hr_dev->caps.reserved_lkey;
|
||||
ib_dev->num_comp_vectors = hr_dev->caps.num_comp_vectors;
|
||||
ib_dev->uverbs_cmd_mask =
|
||||
(1ULL << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ULL << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ULL << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ULL << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ULL << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ULL << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ULL << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ULL << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ULL << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DESTROY_QP);
|
||||
|
||||
ib_dev->uverbs_ex_cmd_mask |= (1ULL << IB_USER_VERBS_EX_CMD_MODIFY_CQ);
|
||||
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_REREG_MR) {
|
||||
ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_REREG_MR);
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_REREG_MR)
|
||||
ib_set_device_ops(ib_dev, &hns_roce_dev_mr_ops);
|
||||
}
|
||||
|
||||
/* MW */
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_MW) {
|
||||
ib_dev->uverbs_cmd_mask |=
|
||||
(1ULL << IB_USER_VERBS_CMD_ALLOC_MW) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DEALLOC_MW);
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_MW)
|
||||
ib_set_device_ops(ib_dev, &hns_roce_dev_mw_ops);
|
||||
}
|
||||
|
||||
/* FRMR */
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_FRMR)
|
||||
@@ -528,12 +509,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
||||
|
||||
/* SRQ */
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) {
|
||||
ib_dev->uverbs_cmd_mask |=
|
||||
(1ULL << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_DESTROY_SRQ) |
|
||||
(1ULL << IB_USER_VERBS_CMD_POST_SRQ_RECV);
|
||||
ib_set_device_ops(ib_dev, &hns_roce_dev_srq_ops);
|
||||
ib_set_device_ops(ib_dev, hr_dev->hw->hns_roce_dev_srq_ops);
|
||||
}
|
||||
@@ -580,8 +555,8 @@ error_failed_setup_mtu_mac:
|
||||
|
||||
static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret;
|
||||
|
||||
ret = hns_roce_init_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table,
|
||||
HEM_TYPE_MTPT, hr_dev->caps.mtpt_entry_sz,
|
||||
@@ -631,7 +606,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
|
||||
goto err_unmap_trrl;
|
||||
}
|
||||
|
||||
if (hr_dev->caps.srqc_entry_sz) {
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) {
|
||||
ret = hns_roce_init_hem_table(hr_dev, &hr_dev->srq_table.table,
|
||||
HEM_TYPE_SRQC,
|
||||
hr_dev->caps.srqc_entry_sz,
|
||||
@@ -643,7 +618,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
|
||||
}
|
||||
}
|
||||
|
||||
if (hr_dev->caps.sccc_sz) {
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL) {
|
||||
ret = hns_roce_init_hem_table(hr_dev,
|
||||
&hr_dev->qp_table.sccc_table,
|
||||
HEM_TYPE_SCCC,
|
||||
@@ -680,18 +655,35 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
|
||||
}
|
||||
}
|
||||
|
||||
if (hr_dev->caps.gmv_entry_sz) {
|
||||
ret = hns_roce_init_hem_table(hr_dev, &hr_dev->gmv_table,
|
||||
HEM_TYPE_GMV,
|
||||
hr_dev->caps.gmv_entry_sz,
|
||||
hr_dev->caps.gmv_entry_num, 1);
|
||||
if (ret) {
|
||||
dev_err(dev,
|
||||
"failed to init gmv table memory, ret = %d\n",
|
||||
ret);
|
||||
goto err_unmap_cqc_timer;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_unmap_cqc_timer:
|
||||
if (hr_dev->caps.cqc_timer_entry_sz)
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->cqc_timer_table);
|
||||
|
||||
err_unmap_qpc_timer:
|
||||
if (hr_dev->caps.qpc_timer_entry_sz)
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qpc_timer_table);
|
||||
|
||||
err_unmap_ctx:
|
||||
if (hr_dev->caps.sccc_sz)
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL)
|
||||
hns_roce_cleanup_hem_table(hr_dev,
|
||||
&hr_dev->qp_table.sccc_table);
|
||||
err_unmap_srq:
|
||||
if (hr_dev->caps.srqc_entry_sz)
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ)
|
||||
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->srq_table.table);
|
||||
|
||||
err_unmap_cq:
|
||||
@@ -721,8 +713,8 @@ err_unmap_dmpt:
|
||||
*/
|
||||
static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret;
|
||||
|
||||
spin_lock_init(&hr_dev->sm_lock);
|
||||
spin_lock_init(&hr_dev->bt_cmd_lock);
|
||||
@@ -846,8 +838,8 @@ void hns_roce_handle_device_err(struct hns_roce_dev *hr_dev)
|
||||
|
||||
int hns_roce_init(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret;
|
||||
|
||||
if (hr_dev->hw->reset) {
|
||||
ret = hr_dev->hw->reset(hr_dev, true);
|
||||
|
||||
@@ -167,10 +167,10 @@ static void hns_roce_mr_free(struct hns_roce_dev *hr_dev,
|
||||
static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_mr *mr)
|
||||
{
|
||||
int ret;
|
||||
unsigned long mtpt_idx = key_to_hw_index(mr->key);
|
||||
struct device *dev = hr_dev->dev;
|
||||
struct hns_roce_cmd_mailbox *mailbox;
|
||||
struct device *dev = hr_dev->dev;
|
||||
int ret;
|
||||
|
||||
/* Allocate mailbox memory */
|
||||
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
|
||||
@@ -185,14 +185,14 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
|
||||
else
|
||||
ret = hr_dev->hw->frmr_write_mtpt(hr_dev, mailbox->buf, mr);
|
||||
if (ret) {
|
||||
dev_err(dev, "Write mtpt fail!\n");
|
||||
dev_err(dev, "failed to write mtpt, ret = %d.\n", ret);
|
||||
goto err_page;
|
||||
}
|
||||
|
||||
ret = hns_roce_hw_create_mpt(hr_dev, mailbox,
|
||||
mtpt_idx & (hr_dev->caps.num_mtpts - 1));
|
||||
if (ret) {
|
||||
dev_err(dev, "CREATE_MPT failed (%d)\n", ret);
|
||||
dev_err(dev, "failed to create mpt, ret = %d.\n", ret);
|
||||
goto err_page;
|
||||
}
|
||||
|
||||
@@ -328,9 +328,10 @@ static int rereg_mr_trans(struct ib_mr *ibmr, int flags,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata)
|
||||
struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(ibmr->device);
|
||||
struct ib_device *ib_dev = &hr_dev->ib_dev;
|
||||
@@ -341,11 +342,11 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
|
||||
int ret;
|
||||
|
||||
if (!mr->enabled)
|
||||
return -EINVAL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
|
||||
if (IS_ERR(mailbox))
|
||||
return PTR_ERR(mailbox);
|
||||
return ERR_CAST(mailbox);
|
||||
|
||||
mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1);
|
||||
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, mtpt_idx, 0,
|
||||
@@ -390,12 +391,12 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
|
||||
|
||||
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
free_cmd_mbox:
|
||||
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
|
||||
|
||||
return ret;
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
|
||||
@@ -495,7 +496,7 @@ int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
|
||||
ret = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, hns_roce_set_page);
|
||||
if (ret < 1) {
|
||||
ibdev_err(ibdev, "failed to store sg pages %d %d, cnt = %d.\n",
|
||||
ibdev_err(ibdev, "failed to store sg pages %u %u, cnt = %d.\n",
|
||||
mr->npages, mr->pbl_mtr.hem_cfg.buf_pg_count, ret);
|
||||
goto err_page_list;
|
||||
}
|
||||
@@ -509,7 +510,7 @@ int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
ibdev_err(ibdev, "failed to map sg mtr, ret = %d.\n", ret);
|
||||
ret = 0;
|
||||
} else {
|
||||
mr->pbl_mtr.hem_cfg.buf_pg_shift = ilog2(ibmr->page_size);
|
||||
mr->pbl_mtr.hem_cfg.buf_pg_shift = (u32)ilog2(ibmr->page_size);
|
||||
ret = mr->npages;
|
||||
}
|
||||
|
||||
@@ -695,15 +696,6 @@ static inline size_t mtr_bufs_size(struct hns_roce_buf_attr *attr)
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline size_t mtr_kmem_direct_size(bool is_direct, size_t alloc_size,
|
||||
unsigned int page_shift)
|
||||
{
|
||||
if (is_direct)
|
||||
return ALIGN(alloc_size, 1 << page_shift);
|
||||
else
|
||||
return HNS_HW_DIRECT_PAGE_COUNT << page_shift;
|
||||
}
|
||||
|
||||
/*
|
||||
* check the given pages in continuous address space
|
||||
* Returns 0 on success, or the error page num.
|
||||
@@ -732,7 +724,6 @@ static void mtr_free_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr)
|
||||
/* release kernel buffers */
|
||||
if (mtr->kmem) {
|
||||
hns_roce_buf_free(hr_dev, mtr->kmem);
|
||||
kfree(mtr->kmem);
|
||||
mtr->kmem = NULL;
|
||||
}
|
||||
}
|
||||
@@ -744,13 +735,12 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
unsigned int best_pg_shift;
|
||||
int all_pg_count = 0;
|
||||
size_t direct_size;
|
||||
size_t total_size;
|
||||
int ret;
|
||||
|
||||
total_size = mtr_bufs_size(buf_attr);
|
||||
if (total_size < 1) {
|
||||
ibdev_err(ibdev, "Failed to check mtr size\n");
|
||||
ibdev_err(ibdev, "failed to check mtr size\n.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -762,7 +752,7 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
mtr->umem = ib_umem_get(ibdev, user_addr, total_size,
|
||||
buf_attr->user_access);
|
||||
if (IS_ERR_OR_NULL(mtr->umem)) {
|
||||
ibdev_err(ibdev, "Failed to get umem, ret %ld\n",
|
||||
ibdev_err(ibdev, "failed to get umem, ret = %ld.\n",
|
||||
PTR_ERR(mtr->umem));
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -780,19 +770,16 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
ret = 0;
|
||||
} else {
|
||||
mtr->umem = NULL;
|
||||
mtr->kmem = kzalloc(sizeof(*mtr->kmem), GFP_KERNEL);
|
||||
if (!mtr->kmem) {
|
||||
ibdev_err(ibdev, "Failed to alloc kmem\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
direct_size = mtr_kmem_direct_size(is_direct, total_size,
|
||||
buf_attr->page_shift);
|
||||
ret = hns_roce_buf_alloc(hr_dev, total_size, direct_size,
|
||||
mtr->kmem, buf_attr->page_shift);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc kmem, ret %d\n", ret);
|
||||
goto err_alloc_mem;
|
||||
mtr->kmem =
|
||||
hns_roce_buf_alloc(hr_dev, total_size,
|
||||
buf_attr->page_shift,
|
||||
is_direct ? HNS_ROCE_BUF_DIRECT : 0);
|
||||
if (IS_ERR(mtr->kmem)) {
|
||||
ibdev_err(ibdev, "failed to alloc kmem, ret = %ld.\n",
|
||||
PTR_ERR(mtr->kmem));
|
||||
return PTR_ERR(mtr->kmem);
|
||||
}
|
||||
|
||||
best_pg_shift = buf_attr->page_shift;
|
||||
all_pg_count = mtr->kmem->npages;
|
||||
}
|
||||
@@ -800,7 +787,8 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
/* must bigger than minimum hardware page shift */
|
||||
if (best_pg_shift < HNS_HW_PAGE_SHIFT || all_pg_count < 1) {
|
||||
ret = -EINVAL;
|
||||
ibdev_err(ibdev, "Failed to check mtr page shift %d count %d\n",
|
||||
ibdev_err(ibdev,
|
||||
"failed to check mtr, page shift = %u count = %d.\n",
|
||||
best_pg_shift, all_pg_count);
|
||||
goto err_alloc_mem;
|
||||
}
|
||||
@@ -841,12 +829,12 @@ static int mtr_get_pages(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
}
|
||||
|
||||
int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
dma_addr_t *pages, int page_cnt)
|
||||
dma_addr_t *pages, unsigned int page_cnt)
|
||||
{
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
struct hns_roce_buf_region *r;
|
||||
unsigned int i;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Only use the first page address as root ba when hopnum is 0, this
|
||||
@@ -862,7 +850,7 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
if (r->offset + r->count > page_cnt) {
|
||||
err = -EINVAL;
|
||||
ibdev_err(ibdev,
|
||||
"Failed to check mtr%d end %d + %d, max %d\n",
|
||||
"failed to check mtr%u end %u + %u, max %u.\n",
|
||||
i, r->offset, r->count, page_cnt);
|
||||
return err;
|
||||
}
|
||||
@@ -870,7 +858,7 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
err = mtr_map_region(hr_dev, mtr, &pages[r->offset], r);
|
||||
if (err) {
|
||||
ibdev_err(ibdev,
|
||||
"Failed to map mtr%d offset %d, err %d\n",
|
||||
"failed to map mtr%u offset %u, ret = %d.\n",
|
||||
i, r->offset, err);
|
||||
return err;
|
||||
}
|
||||
@@ -883,13 +871,12 @@ int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
int offset, u64 *mtt_buf, int mtt_max, u64 *base_addr)
|
||||
{
|
||||
struct hns_roce_hem_cfg *cfg = &mtr->hem_cfg;
|
||||
int mtt_count, left;
|
||||
int start_index;
|
||||
int mtt_count;
|
||||
int total = 0;
|
||||
__le64 *mtts;
|
||||
int npage;
|
||||
u32 npage;
|
||||
u64 addr;
|
||||
int left;
|
||||
|
||||
if (!mtt_buf || mtt_max < 1)
|
||||
goto done;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pci.h>
|
||||
#include <uapi/rdma/hns-abi.h>
|
||||
#include "hns_roce_device.h"
|
||||
|
||||
static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn)
|
||||
@@ -65,21 +64,22 @@ int hns_roce_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
|
||||
|
||||
ret = hns_roce_pd_alloc(to_hr_dev(ib_dev), &pd->pdn);
|
||||
if (ret) {
|
||||
ibdev_err(ib_dev, "failed to alloc pd, ret = %d\n", ret);
|
||||
ibdev_err(ib_dev, "failed to alloc pd, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (udata) {
|
||||
struct hns_roce_ib_alloc_pd_resp uresp = {.pdn = pd->pdn};
|
||||
struct hns_roce_ib_alloc_pd_resp resp = {.pdn = pd->pdn};
|
||||
|
||||
if (ib_copy_to_udata(udata, &uresp, sizeof(uresp))) {
|
||||
ret = ib_copy_to_udata(udata, &resp,
|
||||
min(udata->outlen, sizeof(resp)));
|
||||
if (ret) {
|
||||
hns_roce_pd_free(to_hr_dev(ib_dev), pd->pdn);
|
||||
ibdev_err(ib_dev, "failed to copy to udata\n");
|
||||
return -EFAULT;
|
||||
ibdev_err(ib_dev, "failed to copy to udata, ret = %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata)
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "hns_roce_common.h"
|
||||
#include "hns_roce_device.h"
|
||||
#include "hns_roce_hem.h"
|
||||
#include <rdma/hns-abi.h>
|
||||
|
||||
static void flush_work_handle(struct work_struct *work)
|
||||
{
|
||||
@@ -114,8 +113,8 @@ void hns_roce_qp_event(struct hns_roce_dev *hr_dev, u32 qpn, int event_type)
|
||||
static void hns_roce_ib_qp_event(struct hns_roce_qp *hr_qp,
|
||||
enum hns_roce_event type)
|
||||
{
|
||||
struct ib_event event;
|
||||
struct ib_qp *ibqp = &hr_qp->ibqp;
|
||||
struct ib_event event;
|
||||
|
||||
if (ibqp->event_handler) {
|
||||
event.device = ibqp->device;
|
||||
@@ -154,9 +153,50 @@ static void hns_roce_ib_qp_event(struct hns_roce_qp *hr_qp,
|
||||
}
|
||||
}
|
||||
|
||||
static u8 get_least_load_bankid_for_qp(struct hns_roce_bank *bank)
|
||||
{
|
||||
u32 least_load = bank[0].inuse;
|
||||
u8 bankid = 0;
|
||||
u32 bankcnt;
|
||||
u8 i;
|
||||
|
||||
for (i = 1; i < HNS_ROCE_QP_BANK_NUM; i++) {
|
||||
bankcnt = bank[i].inuse;
|
||||
if (bankcnt < least_load) {
|
||||
least_load = bankcnt;
|
||||
bankid = i;
|
||||
}
|
||||
}
|
||||
|
||||
return bankid;
|
||||
}
|
||||
|
||||
static int alloc_qpn_with_bankid(struct hns_roce_bank *bank, u8 bankid,
|
||||
unsigned long *qpn)
|
||||
{
|
||||
int id;
|
||||
|
||||
id = ida_alloc_range(&bank->ida, bank->next, bank->max, GFP_KERNEL);
|
||||
if (id < 0) {
|
||||
id = ida_alloc_range(&bank->ida, bank->min, bank->max,
|
||||
GFP_KERNEL);
|
||||
if (id < 0)
|
||||
return id;
|
||||
}
|
||||
|
||||
/* the QPN should keep increasing until the max value is reached. */
|
||||
bank->next = (id + 1) > bank->max ? bank->min : id + 1;
|
||||
|
||||
/* the lower 3 bits is bankid */
|
||||
*qpn = (id << 3) | bankid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int alloc_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
{
|
||||
struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
|
||||
unsigned long num = 0;
|
||||
u8 bankid;
|
||||
int ret;
|
||||
|
||||
if (hr_qp->ibqp.qp_type == IB_QPT_GSI) {
|
||||
@@ -169,13 +209,21 @@ static int alloc_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
|
||||
hr_qp->doorbell_qpn = 1;
|
||||
} else {
|
||||
ret = hns_roce_bitmap_alloc_range(&hr_dev->qp_table.bitmap,
|
||||
1, 1, &num);
|
||||
spin_lock(&qp_table->bank_lock);
|
||||
bankid = get_least_load_bankid_for_qp(qp_table->bank);
|
||||
|
||||
ret = alloc_qpn_with_bankid(&qp_table->bank[bankid], bankid,
|
||||
&num);
|
||||
if (ret) {
|
||||
ibdev_err(&hr_dev->ib_dev, "Failed to alloc bitmap\n");
|
||||
return -ENOMEM;
|
||||
ibdev_err(&hr_dev->ib_dev,
|
||||
"failed to alloc QPN, ret = %d\n", ret);
|
||||
spin_unlock(&qp_table->bank_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
qp_table->bank[bankid].inuse++;
|
||||
spin_unlock(&qp_table->bank_lock);
|
||||
|
||||
hr_qp->doorbell_qpn = (u32)num;
|
||||
}
|
||||
|
||||
@@ -286,7 +334,7 @@ static int alloc_qpc(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
}
|
||||
}
|
||||
|
||||
if (hr_dev->caps.sccc_sz) {
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL) {
|
||||
/* Alloc memory for SCC CTX */
|
||||
ret = hns_roce_table_get(hr_dev, &qp_table->sccc_table,
|
||||
hr_qp->qpn);
|
||||
@@ -340,9 +388,15 @@ static void free_qpc(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
hns_roce_table_put(hr_dev, &qp_table->irrl_table, hr_qp->qpn);
|
||||
}
|
||||
|
||||
static inline u8 get_qp_bankid(unsigned long qpn)
|
||||
{
|
||||
/* The lower 3 bits of QPN are used to hash to different banks */
|
||||
return (u8)(qpn & GENMASK(2, 0));
|
||||
}
|
||||
|
||||
static void free_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
{
|
||||
struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
|
||||
u8 bankid;
|
||||
|
||||
if (hr_qp->ibqp.qp_type == IB_QPT_GSI)
|
||||
return;
|
||||
@@ -350,7 +404,13 @@ static void free_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
|
||||
if (hr_qp->qpn < hr_dev->caps.reserved_qps)
|
||||
return;
|
||||
|
||||
hns_roce_bitmap_free_range(&qp_table->bitmap, hr_qp->qpn, 1, BITMAP_RR);
|
||||
bankid = get_qp_bankid(hr_qp->qpn);
|
||||
|
||||
ida_free(&hr_dev->qp_table.bank[bankid].ida, hr_qp->qpn >> 3);
|
||||
|
||||
spin_lock(&hr_dev->qp_table.bank_lock);
|
||||
hr_dev->qp_table.bank[bankid].inuse--;
|
||||
spin_unlock(&hr_dev->qp_table.bank_lock);
|
||||
}
|
||||
|
||||
static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap,
|
||||
@@ -404,39 +464,45 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,
|
||||
struct hns_roce_qp *hr_qp,
|
||||
struct ib_qp_cap *cap)
|
||||
static u32 get_wqe_ext_sge_cnt(struct hns_roce_qp *qp)
|
||||
{
|
||||
u32 cnt;
|
||||
/* GSI/UD QP only has extended sge */
|
||||
if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_UD)
|
||||
return qp->sq.max_gs;
|
||||
|
||||
cnt = max(1U, cap->max_send_sge);
|
||||
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
|
||||
hr_qp->sq.max_gs = roundup_pow_of_two(cnt);
|
||||
hr_qp->sge.sge_cnt = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
hr_qp->sq.max_gs = cnt;
|
||||
|
||||
/* UD sqwqe's sge use extend sge */
|
||||
if (hr_qp->ibqp.qp_type == IB_QPT_GSI ||
|
||||
hr_qp->ibqp.qp_type == IB_QPT_UD) {
|
||||
cnt = roundup_pow_of_two(sq_wqe_cnt * hr_qp->sq.max_gs);
|
||||
} else if (hr_qp->sq.max_gs > HNS_ROCE_SGE_IN_WQE) {
|
||||
cnt = roundup_pow_of_two(sq_wqe_cnt *
|
||||
(hr_qp->sq.max_gs - HNS_ROCE_SGE_IN_WQE));
|
||||
} else {
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT;
|
||||
hr_qp->sge.sge_cnt = cnt;
|
||||
if (qp->sq.max_gs > HNS_ROCE_SGE_IN_WQE)
|
||||
return qp->sq.max_gs - HNS_ROCE_SGE_IN_WQE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_ext_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,
|
||||
struct hns_roce_qp *hr_qp, struct ib_qp_cap *cap)
|
||||
{
|
||||
u32 total_sge_cnt;
|
||||
u32 wqe_sge_cnt;
|
||||
|
||||
hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT;
|
||||
|
||||
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
|
||||
hr_qp->sq.max_gs = HNS_ROCE_SGE_IN_WQE;
|
||||
return;
|
||||
}
|
||||
|
||||
hr_qp->sq.max_gs = max(1U, cap->max_send_sge);
|
||||
|
||||
wqe_sge_cnt = get_wqe_ext_sge_cnt(hr_qp);
|
||||
|
||||
/* If the number of extended sge is not zero, they MUST use the
|
||||
* space of HNS_HW_PAGE_SIZE at least.
|
||||
*/
|
||||
if (wqe_sge_cnt) {
|
||||
total_sge_cnt = roundup_pow_of_two(sq_wqe_cnt * wqe_sge_cnt);
|
||||
hr_qp->sge.sge_cnt = max(total_sge_cnt,
|
||||
(u32)HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static int check_sq_size_with_integrity(struct hns_roce_dev *hr_dev,
|
||||
struct ib_qp_cap *cap,
|
||||
struct hns_roce_ib_create_qp *ucmd)
|
||||
@@ -447,12 +513,12 @@ static int check_sq_size_with_integrity(struct hns_roce_dev *hr_dev,
|
||||
/* Sanity check SQ size before proceeding */
|
||||
if (ucmd->log_sq_stride > max_sq_stride ||
|
||||
ucmd->log_sq_stride < HNS_ROCE_IB_MIN_SQ_STRIDE) {
|
||||
ibdev_err(&hr_dev->ib_dev, "Failed to check SQ stride size\n");
|
||||
ibdev_err(&hr_dev->ib_dev, "failed to check SQ stride size.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cap->max_send_sge > hr_dev->caps.max_sq_sg) {
|
||||
ibdev_err(&hr_dev->ib_dev, "Failed to check SQ SGE size %d\n",
|
||||
ibdev_err(&hr_dev->ib_dev, "failed to check SQ SGE size %u.\n",
|
||||
cap->max_send_sge);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -479,9 +545,7 @@ static int set_user_sq_size(struct hns_roce_dev *hr_dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = set_extend_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||
if (ret)
|
||||
return ret;
|
||||
set_ext_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||
|
||||
hr_qp->sq.wqe_shift = ucmd->log_sq_stride;
|
||||
hr_qp->sq.wqe_cnt = cnt;
|
||||
@@ -546,7 +610,6 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
|
||||
{
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
u32 cnt;
|
||||
int ret;
|
||||
|
||||
if (!cap->max_send_wr || cap->max_send_wr > hr_dev->caps.max_wqes ||
|
||||
cap->max_send_sge > hr_dev->caps.max_sq_sg) {
|
||||
@@ -558,7 +621,7 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
|
||||
|
||||
cnt = roundup_pow_of_two(max(cap->max_send_wr, hr_dev->caps.min_wqes));
|
||||
if (cnt > hr_dev->caps.max_wqes) {
|
||||
ibdev_err(ibdev, "failed to check WQE num, WQE num = %d.\n",
|
||||
ibdev_err(ibdev, "failed to check WQE num, WQE num = %u.\n",
|
||||
cnt);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -566,9 +629,7 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
|
||||
hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
|
||||
hr_qp->sq.wqe_cnt = cnt;
|
||||
|
||||
ret = set_extend_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||
if (ret)
|
||||
return ret;
|
||||
set_ext_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||
|
||||
/* sync the parameters of kernel QP to user's configuration */
|
||||
cap->max_send_wr = cnt;
|
||||
@@ -725,13 +786,17 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
int ret;
|
||||
|
||||
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SDI_MODE)
|
||||
hr_qp->en_flags |= HNS_ROCE_QP_CAP_OWNER_DB;
|
||||
|
||||
if (udata) {
|
||||
if (user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd)) {
|
||||
ret = hns_roce_db_map_user(uctx, udata, ucmd->sdb_addr,
|
||||
&hr_qp->sdb);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev,
|
||||
"Failed to map user SQ doorbell\n");
|
||||
"failed to map user SQ doorbell, ret = %d.\n",
|
||||
ret);
|
||||
goto err_out;
|
||||
}
|
||||
hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
|
||||
@@ -743,7 +808,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
&hr_qp->rdb);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev,
|
||||
"Failed to map user RQ doorbell\n");
|
||||
"failed to map user RQ doorbell, ret = %d.\n",
|
||||
ret);
|
||||
goto err_sdb;
|
||||
}
|
||||
hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
|
||||
@@ -760,7 +826,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
ret = hns_roce_alloc_db(hr_dev, &hr_qp->rdb, 0);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev,
|
||||
"Failed to alloc kernel RQ doorbell\n");
|
||||
"failed to alloc kernel RQ doorbell, ret = %d.\n",
|
||||
ret);
|
||||
goto err_out;
|
||||
}
|
||||
*hr_qp->rdb.db_record = 0;
|
||||
@@ -803,14 +870,14 @@ static int alloc_kernel_wrid(struct hns_roce_dev *hr_dev,
|
||||
|
||||
sq_wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64), GFP_KERNEL);
|
||||
if (ZERO_OR_NULL_PTR(sq_wrid)) {
|
||||
ibdev_err(ibdev, "Failed to alloc SQ wrid\n");
|
||||
ibdev_err(ibdev, "failed to alloc SQ wrid.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (hr_qp->rq.wqe_cnt) {
|
||||
rq_wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64), GFP_KERNEL);
|
||||
if (ZERO_OR_NULL_PTR(rq_wrid)) {
|
||||
ibdev_err(ibdev, "Failed to alloc RQ wrid\n");
|
||||
ibdev_err(ibdev, "failed to alloc RQ wrid.\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_sq;
|
||||
}
|
||||
@@ -860,29 +927,25 @@ static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
}
|
||||
|
||||
if (udata) {
|
||||
if (ib_copy_from_udata(ucmd, udata, sizeof(*ucmd))) {
|
||||
ibdev_err(ibdev, "Failed to copy QP ucmd\n");
|
||||
return -EFAULT;
|
||||
ret = ib_copy_from_udata(ucmd, udata,
|
||||
min(udata->inlen, sizeof(*ucmd)));
|
||||
if (ret) {
|
||||
ibdev_err(ibdev,
|
||||
"failed to copy QP ucmd, ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = set_user_sq_size(hr_dev, &init_attr->cap, hr_qp, ucmd);
|
||||
if (ret)
|
||||
ibdev_err(ibdev, "Failed to set user SQ size\n");
|
||||
ibdev_err(ibdev,
|
||||
"failed to set user SQ size, ret = %d.\n",
|
||||
ret);
|
||||
} else {
|
||||
if (init_attr->create_flags &
|
||||
IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) {
|
||||
ibdev_err(ibdev, "Failed to check multicast loopback\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO) {
|
||||
ibdev_err(ibdev, "Failed to check ipoib ud lso\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = set_kernel_sq_size(hr_dev, &init_attr->cap, hr_qp);
|
||||
if (ret)
|
||||
ibdev_err(ibdev, "Failed to set kernel SQ size\n");
|
||||
ibdev_err(ibdev,
|
||||
"failed to set kernel SQ size, ret = %d.\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -906,47 +969,53 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
|
||||
hr_qp->state = IB_QPS_RESET;
|
||||
hr_qp->flush_flag = 0;
|
||||
|
||||
if (init_attr->create_flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = set_qp_param(hr_dev, hr_qp, init_attr, udata, &ucmd);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to set QP param\n");
|
||||
ibdev_err(ibdev, "failed to set QP param, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!udata) {
|
||||
ret = alloc_kernel_wrid(hr_dev, hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc wrid\n");
|
||||
ibdev_err(ibdev, "failed to alloc wrid, ret = %d.\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = alloc_qp_db(hr_dev, hr_qp, init_attr, udata, &ucmd, &resp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc QP doorbell\n");
|
||||
ibdev_err(ibdev, "failed to alloc QP doorbell, ret = %d.\n",
|
||||
ret);
|
||||
goto err_wrid;
|
||||
}
|
||||
|
||||
ret = alloc_qp_buf(hr_dev, hr_qp, init_attr, udata, ucmd.buf_addr);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc QP buffer\n");
|
||||
ibdev_err(ibdev, "failed to alloc QP buffer, ret = %d.\n", ret);
|
||||
goto err_db;
|
||||
}
|
||||
|
||||
ret = alloc_qpn(hr_dev, hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc QPN\n");
|
||||
ibdev_err(ibdev, "failed to alloc QPN, ret = %d.\n", ret);
|
||||
goto err_buf;
|
||||
}
|
||||
|
||||
ret = alloc_qpc(hr_dev, hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc QP context\n");
|
||||
ibdev_err(ibdev, "failed to alloc QP context, ret = %d.\n",
|
||||
ret);
|
||||
goto err_qpn;
|
||||
}
|
||||
|
||||
ret = hns_roce_qp_store(hr_dev, hr_qp, init_attr);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to store QP\n");
|
||||
ibdev_err(ibdev, "failed to store QP, ret = %d.\n", ret);
|
||||
goto err_qpc;
|
||||
}
|
||||
|
||||
@@ -1003,6 +1072,30 @@ void hns_roce_qp_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
kfree(hr_qp);
|
||||
}
|
||||
|
||||
static int check_qp_type(struct hns_roce_dev *hr_dev, enum ib_qp_type type,
|
||||
bool is_user)
|
||||
{
|
||||
switch (type) {
|
||||
case IB_QPT_UD:
|
||||
if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 &&
|
||||
is_user)
|
||||
goto out;
|
||||
fallthrough;
|
||||
case IB_QPT_RC:
|
||||
case IB_QPT_GSI:
|
||||
break;
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
ibdev_err(&hr_dev->ib_dev, "not support QP type %d\n", type);
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
@@ -1012,15 +1105,9 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
struct hns_roce_qp *hr_qp;
|
||||
int ret;
|
||||
|
||||
switch (init_attr->qp_type) {
|
||||
case IB_QPT_RC:
|
||||
case IB_QPT_GSI:
|
||||
break;
|
||||
default:
|
||||
ibdev_err(ibdev, "not support QP type %d\n",
|
||||
init_attr->qp_type);
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
ret = check_qp_type(hr_dev, init_attr->qp_type, !!udata);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
|
||||
if (!hr_qp)
|
||||
@@ -1035,10 +1122,11 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Create QP type 0x%x failed(%d)\n",
|
||||
init_attr->qp_type, ret);
|
||||
ibdev_err(ibdev, "Create GSI QP failed!\n");
|
||||
|
||||
kfree(hr_qp);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return &hr_qp->ibqp;
|
||||
}
|
||||
|
||||
@@ -1091,9 +1179,8 @@ static int hns_roce_check_qp_attr(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
|
||||
if ((attr_mask & IB_QP_PORT) &&
|
||||
(attr->port_num == 0 || attr->port_num > hr_dev->caps.num_ports)) {
|
||||
ibdev_err(&hr_dev->ib_dev,
|
||||
"attr port_num invalid.attr->port_num=%d\n",
|
||||
attr->port_num);
|
||||
ibdev_err(&hr_dev->ib_dev, "invalid attr, port_num = %u.\n",
|
||||
attr->port_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1101,8 +1188,8 @@ static int hns_roce_check_qp_attr(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) : hr_qp->port;
|
||||
if (attr->pkey_index >= hr_dev->caps.pkey_table_len[p]) {
|
||||
ibdev_err(&hr_dev->ib_dev,
|
||||
"attr pkey_index invalid.attr->pkey_index=%d\n",
|
||||
attr->pkey_index);
|
||||
"invalid attr, pkey_index = %u.\n",
|
||||
attr->pkey_index);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
@@ -1110,16 +1197,16 @@ static int hns_roce_check_qp_attr(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
|
||||
attr->max_rd_atomic > hr_dev->caps.max_qp_init_rdma) {
|
||||
ibdev_err(&hr_dev->ib_dev,
|
||||
"attr max_rd_atomic invalid.attr->max_rd_atomic=%d\n",
|
||||
attr->max_rd_atomic);
|
||||
"invalid attr, max_rd_atomic = %u.\n",
|
||||
attr->max_rd_atomic);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
|
||||
attr->max_dest_rd_atomic > hr_dev->caps.max_qp_dest_rdma) {
|
||||
ibdev_err(&hr_dev->ib_dev,
|
||||
"attr max_dest_rd_atomic invalid.attr->max_dest_rd_atomic=%d\n",
|
||||
attr->max_dest_rd_atomic);
|
||||
"invalid attr, max_dest_rd_atomic = %u.\n",
|
||||
attr->max_dest_rd_atomic);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1244,22 +1331,22 @@ static inline void *get_wqe(struct hns_roce_qp *hr_qp, int offset)
|
||||
return hns_roce_buf_offset(hr_qp->mtr.kmem, offset);
|
||||
}
|
||||
|
||||
void *hns_roce_get_recv_wqe(struct hns_roce_qp *hr_qp, int n)
|
||||
void *hns_roce_get_recv_wqe(struct hns_roce_qp *hr_qp, unsigned int n)
|
||||
{
|
||||
return get_wqe(hr_qp, hr_qp->rq.offset + (n << hr_qp->rq.wqe_shift));
|
||||
}
|
||||
|
||||
void *hns_roce_get_send_wqe(struct hns_roce_qp *hr_qp, int n)
|
||||
void *hns_roce_get_send_wqe(struct hns_roce_qp *hr_qp, unsigned int n)
|
||||
{
|
||||
return get_wqe(hr_qp, hr_qp->sq.offset + (n << hr_qp->sq.wqe_shift));
|
||||
}
|
||||
|
||||
void *hns_roce_get_extend_sge(struct hns_roce_qp *hr_qp, int n)
|
||||
void *hns_roce_get_extend_sge(struct hns_roce_qp *hr_qp, unsigned int n)
|
||||
{
|
||||
return get_wqe(hr_qp, hr_qp->sge.offset + (n << hr_qp->sge.sge_shift));
|
||||
}
|
||||
|
||||
bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
|
||||
bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, u32 nreq,
|
||||
struct ib_cq *ib_cq)
|
||||
{
|
||||
struct hns_roce_cq *hr_cq;
|
||||
@@ -1280,22 +1367,24 @@ bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
|
||||
int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
|
||||
int reserved_from_top = 0;
|
||||
int reserved_from_bot;
|
||||
int ret;
|
||||
unsigned int reserved_from_bot;
|
||||
unsigned int i;
|
||||
|
||||
mutex_init(&qp_table->scc_mutex);
|
||||
xa_init(&hr_dev->qp_table_xa);
|
||||
|
||||
reserved_from_bot = hr_dev->caps.reserved_qps;
|
||||
|
||||
ret = hns_roce_bitmap_init(&qp_table->bitmap, hr_dev->caps.num_qps,
|
||||
hr_dev->caps.num_qps - 1, reserved_from_bot,
|
||||
reserved_from_top);
|
||||
if (ret) {
|
||||
dev_err(hr_dev->dev, "qp bitmap init failed!error=%d\n",
|
||||
ret);
|
||||
return ret;
|
||||
for (i = 0; i < reserved_from_bot; i++) {
|
||||
hr_dev->qp_table.bank[get_qp_bankid(i)].inuse++;
|
||||
hr_dev->qp_table.bank[get_qp_bankid(i)].min++;
|
||||
}
|
||||
|
||||
for (i = 0; i < HNS_ROCE_QP_BANK_NUM; i++) {
|
||||
ida_init(&hr_dev->qp_table.bank[i].ida);
|
||||
hr_dev->qp_table.bank[i].max = hr_dev->caps.num_qps /
|
||||
HNS_ROCE_QP_BANK_NUM - 1;
|
||||
hr_dev->qp_table.bank[i].next = hr_dev->qp_table.bank[i].min;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1303,5 +1392,8 @@ int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev)
|
||||
|
||||
void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
hns_roce_bitmap_cleanup(&hr_dev->qp_table.bitmap);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HNS_ROCE_QP_BANK_NUM; i++)
|
||||
ida_destroy(&hr_dev->qp_table.bank[i].ida);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#include <rdma/ib_umem.h>
|
||||
#include <rdma/hns-abi.h>
|
||||
#include "hns_roce_device.h"
|
||||
#include "hns_roce_cmd.h"
|
||||
#include "hns_roce_hem.h"
|
||||
@@ -93,7 +92,8 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
|
||||
ret = hns_roce_mtr_find(hr_dev, &srq->buf_mtr, 0, mtts_wqe,
|
||||
ARRAY_SIZE(mtts_wqe), &dma_handle_wqe);
|
||||
if (ret < 1) {
|
||||
ibdev_err(ibdev, "Failed to find mtr for SRQ WQE\n");
|
||||
ibdev_err(ibdev, "failed to find mtr for SRQ WQE, ret = %d.\n",
|
||||
ret);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
@@ -101,32 +101,34 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
|
||||
ret = hns_roce_mtr_find(hr_dev, &srq->idx_que.mtr, 0, mtts_idx,
|
||||
ARRAY_SIZE(mtts_idx), &dma_handle_idx);
|
||||
if (ret < 1) {
|
||||
ibdev_err(ibdev, "Failed to find mtr for SRQ idx\n");
|
||||
ibdev_err(ibdev, "failed to find mtr for SRQ idx, ret = %d.\n",
|
||||
ret);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ number, err %d\n", ret);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc SRQ number, ret = %d.\n", ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to get SRQC table, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to get SRQC table, ret = %d.\n", ret);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL));
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to store SRQC, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret);
|
||||
goto err_put;
|
||||
}
|
||||
|
||||
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
|
||||
if (IS_ERR_OR_NULL(mailbox)) {
|
||||
ret = -ENOMEM;
|
||||
ibdev_err(ibdev, "Failed to alloc mailbox for SRQC\n");
|
||||
ibdev_err(ibdev, "failed to alloc mailbox for SRQC.\n");
|
||||
goto err_xa;
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
|
||||
ret = hns_roce_hw_create_srq(hr_dev, mailbox, srq->srqn);
|
||||
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to config SRQC, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to config SRQC, ret = %d.\n", ret);
|
||||
goto err_xa;
|
||||
}
|
||||
|
||||
@@ -198,7 +200,8 @@ static int alloc_srq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
|
||||
hr_dev->caps.srqwqe_ba_pg_sz +
|
||||
HNS_HW_PAGE_SHIFT, udata, addr);
|
||||
if (err)
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ buf mtr, err %d\n", err);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc SRQ buf mtr, ret = %d.\n", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -229,18 +232,18 @@ static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
|
||||
hr_dev->caps.idx_ba_pg_sz + HNS_HW_PAGE_SHIFT,
|
||||
udata, addr);
|
||||
if (err) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ idx mtr, err %d\n", err);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc SRQ idx mtr, ret = %d.\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!udata) {
|
||||
idx_que->bitmap = bitmap_zalloc(srq->wqe_cnt, GFP_KERNEL);
|
||||
if (!idx_que->bitmap) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ idx bitmap\n");
|
||||
ibdev_err(ibdev, "failed to alloc SRQ idx bitmap.\n");
|
||||
err = -ENOMEM;
|
||||
goto err_idx_mtr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -288,6 +291,10 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
|
||||
int ret;
|
||||
u32 cqn;
|
||||
|
||||
if (init_attr->srq_type != IB_SRQT_BASIC &&
|
||||
init_attr->srq_type != IB_SRQT_XRC)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Check the actual SRQ wqe and SRQ sge num */
|
||||
if (init_attr->attr.max_wr >= hr_dev->caps.max_srq_wrs ||
|
||||
init_attr->attr.max_sge > hr_dev->caps.max_srq_sges)
|
||||
@@ -300,9 +307,10 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
|
||||
srq->max_gs = init_attr->attr.max_sge;
|
||||
|
||||
if (udata) {
|
||||
ret = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
|
||||
ret = ib_copy_from_udata(&ucmd, udata,
|
||||
min(udata->inlen, sizeof(ucmd)));
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to copy SRQ udata, err %d\n",
|
||||
ibdev_err(ibdev, "failed to copy SRQ udata, ret = %d.\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -310,20 +318,21 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
|
||||
|
||||
ret = alloc_srq_buf(hr_dev, srq, udata, ucmd.buf_addr);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ buffer, err %d\n", ret);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc SRQ buffer, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = alloc_srq_idx(hr_dev, srq, udata, ucmd.que_addr);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ idx, err %d\n", ret);
|
||||
ibdev_err(ibdev, "failed to alloc SRQ idx, ret = %d.\n", ret);
|
||||
goto err_buf_alloc;
|
||||
}
|
||||
|
||||
if (!udata) {
|
||||
ret = alloc_srq_wrid(hr_dev, srq);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ wrid, err %d\n",
|
||||
ibdev_err(ibdev, "failed to alloc SRQ wrid, ret = %d.\n",
|
||||
ret);
|
||||
goto err_idx_alloc;
|
||||
}
|
||||
@@ -335,7 +344,8 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
|
||||
|
||||
ret = alloc_srqc(hr_dev, srq, to_hr_pd(ib_srq->pd)->pdn, cqn, 0, 0);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Failed to alloc SRQ context, err %d\n", ret);
|
||||
ibdev_err(ibdev,
|
||||
"failed to alloc SRQ context, ret = %d.\n", ret);
|
||||
goto err_wrid_alloc;
|
||||
}
|
||||
|
||||
@@ -343,11 +353,10 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
|
||||
resp.srqn = srq->srqn;
|
||||
|
||||
if (udata) {
|
||||
if (ib_copy_to_udata(udata, &resp,
|
||||
min(udata->outlen, sizeof(resp)))) {
|
||||
ret = -EFAULT;
|
||||
ret = ib_copy_to_udata(udata, &resp,
|
||||
min(udata->outlen, sizeof(resp)));
|
||||
if (ret)
|
||||
goto err_srqc_alloc;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -274,7 +274,6 @@ struct i40iw_device {
|
||||
u8 max_sge;
|
||||
u8 iw_status;
|
||||
u8 send_term_ok;
|
||||
bool push_mode; /* Initialized from parameter passed to driver */
|
||||
|
||||
/* x710 specific */
|
||||
struct mutex pbl_mutex;
|
||||
|
||||
@@ -2426,7 +2426,7 @@ static void i40iw_handle_rst_pkt(struct i40iw_cm_node *cm_node,
|
||||
}
|
||||
break;
|
||||
case I40IW_CM_STATE_MPAREQ_RCVD:
|
||||
atomic_add_return(1, &cm_node->passive_state);
|
||||
atomic_inc(&cm_node->passive_state);
|
||||
break;
|
||||
case I40IW_CM_STATE_ESTABLISHED:
|
||||
case I40IW_CM_STATE_SYN_RCVD:
|
||||
@@ -3020,7 +3020,7 @@ static int i40iw_cm_reject(struct i40iw_cm_node *cm_node, const void *pdata, u8
|
||||
i40iw_cleanup_retrans_entry(cm_node);
|
||||
|
||||
if (!loopback) {
|
||||
passive_state = atomic_add_return(1, &cm_node->passive_state);
|
||||
passive_state = atomic_inc_return(&cm_node->passive_state);
|
||||
if (passive_state == I40IW_SEND_RESET_EVENT) {
|
||||
cm_node->state = I40IW_CM_STATE_CLOSED;
|
||||
i40iw_rem_ref_cm_node(cm_node);
|
||||
@@ -3678,7 +3678,7 @@ int i40iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
passive_state = atomic_add_return(1, &cm_node->passive_state);
|
||||
passive_state = atomic_inc_return(&cm_node->passive_state);
|
||||
if (passive_state == I40IW_SEND_RESET_EVENT) {
|
||||
i40iw_rem_ref_cm_node(cm_node);
|
||||
return -ECONNRESET;
|
||||
|
||||
@@ -819,46 +819,6 @@ static enum i40iw_status_code i40iw_sc_poll_for_cqp_op_done(
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_sc_manage_push_page - Handle push page
|
||||
* @cqp: struct for cqp hw
|
||||
* @info: push page info
|
||||
* @scratch: u64 saved to be used during cqp completion
|
||||
* @post_sq: flag for cqp db to ring
|
||||
*/
|
||||
static enum i40iw_status_code i40iw_sc_manage_push_page(
|
||||
struct i40iw_sc_cqp *cqp,
|
||||
struct i40iw_cqp_manage_push_page_info *info,
|
||||
u64 scratch,
|
||||
bool post_sq)
|
||||
{
|
||||
u64 *wqe;
|
||||
u64 header;
|
||||
|
||||
if (info->push_idx >= I40IW_MAX_PUSH_PAGE_COUNT)
|
||||
return I40IW_ERR_INVALID_PUSH_PAGE_INDEX;
|
||||
|
||||
wqe = i40iw_sc_cqp_get_next_send_wqe(cqp, scratch);
|
||||
if (!wqe)
|
||||
return I40IW_ERR_RING_FULL;
|
||||
|
||||
set_64bit_val(wqe, 16, info->qs_handle);
|
||||
|
||||
header = LS_64(info->push_idx, I40IW_CQPSQ_MPP_PPIDX) |
|
||||
LS_64(I40IW_CQP_OP_MANAGE_PUSH_PAGES, I40IW_CQPSQ_OPCODE) |
|
||||
LS_64(cqp->polarity, I40IW_CQPSQ_WQEVALID) |
|
||||
LS_64(info->free_page, I40IW_CQPSQ_MPP_FREE_PAGE);
|
||||
|
||||
i40iw_insert_wqe_hdr(wqe, header);
|
||||
|
||||
i40iw_debug_buf(cqp->dev, I40IW_DEBUG_WQE, "MANAGE_PUSH_PAGES WQE",
|
||||
wqe, I40IW_CQP_WQE_SIZE * 8);
|
||||
|
||||
if (post_sq)
|
||||
i40iw_sc_cqp_post_sq(cqp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_sc_manage_hmc_pm_func_table - manage of function table
|
||||
* @cqp: struct for cqp hw
|
||||
@@ -2859,9 +2819,7 @@ static enum i40iw_status_code i40iw_sc_qp_setctx(
|
||||
LS_64(qp->rcv_tph_en, I40IWQPC_RCVTPHEN) |
|
||||
LS_64(qp->xmit_tph_en, I40IWQPC_XMITTPHEN) |
|
||||
LS_64(qp->rq_tph_en, I40IWQPC_RQTPHEN) |
|
||||
LS_64(qp->sq_tph_en, I40IWQPC_SQTPHEN) |
|
||||
LS_64(info->push_idx, I40IWQPC_PPIDX) |
|
||||
LS_64(info->push_mode_en, I40IWQPC_PMENA);
|
||||
LS_64(qp->sq_tph_en, I40IWQPC_SQTPHEN);
|
||||
|
||||
set_64bit_val(qp_ctx, 8, qp->sq_pa);
|
||||
set_64bit_val(qp_ctx, 16, qp->rq_pa);
|
||||
@@ -4291,13 +4249,6 @@ static enum i40iw_status_code i40iw_exec_cqp_cmd(struct i40iw_sc_dev *dev,
|
||||
pcmdinfo->in.u.add_arp_cache_entry.scratch,
|
||||
pcmdinfo->post_sq);
|
||||
break;
|
||||
case OP_MANAGE_PUSH_PAGE:
|
||||
status = i40iw_sc_manage_push_page(
|
||||
pcmdinfo->in.u.manage_push_page.cqp,
|
||||
&pcmdinfo->in.u.manage_push_page.info,
|
||||
pcmdinfo->in.u.manage_push_page.scratch,
|
||||
pcmdinfo->post_sq);
|
||||
break;
|
||||
case OP_UPDATE_PE_SDS:
|
||||
/* case I40IW_CQP_OP_UPDATE_PE_SDS */
|
||||
status = i40iw_update_pe_sds(
|
||||
@@ -5098,7 +5049,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi)
|
||||
i40iw_hw_stats_stop_timer(vsi);
|
||||
}
|
||||
|
||||
static struct i40iw_cqp_ops iw_cqp_ops = {
|
||||
static const struct i40iw_cqp_ops iw_cqp_ops = {
|
||||
.cqp_init = i40iw_sc_cqp_init,
|
||||
.cqp_create = i40iw_sc_cqp_create,
|
||||
.cqp_post_sq = i40iw_sc_cqp_post_sq,
|
||||
@@ -5107,7 +5058,7 @@ static struct i40iw_cqp_ops iw_cqp_ops = {
|
||||
.poll_for_cqp_op_done = i40iw_sc_poll_for_cqp_op_done
|
||||
};
|
||||
|
||||
static struct i40iw_ccq_ops iw_ccq_ops = {
|
||||
static const struct i40iw_ccq_ops iw_ccq_ops = {
|
||||
.ccq_init = i40iw_sc_ccq_init,
|
||||
.ccq_create = i40iw_sc_ccq_create,
|
||||
.ccq_destroy = i40iw_sc_ccq_destroy,
|
||||
@@ -5116,7 +5067,7 @@ static struct i40iw_ccq_ops iw_ccq_ops = {
|
||||
.ccq_arm = i40iw_sc_ccq_arm
|
||||
};
|
||||
|
||||
static struct i40iw_ceq_ops iw_ceq_ops = {
|
||||
static const struct i40iw_ceq_ops iw_ceq_ops = {
|
||||
.ceq_init = i40iw_sc_ceq_init,
|
||||
.ceq_create = i40iw_sc_ceq_create,
|
||||
.cceq_create_done = i40iw_sc_cceq_create_done,
|
||||
@@ -5126,7 +5077,7 @@ static struct i40iw_ceq_ops iw_ceq_ops = {
|
||||
.process_ceq = i40iw_sc_process_ceq
|
||||
};
|
||||
|
||||
static struct i40iw_aeq_ops iw_aeq_ops = {
|
||||
static const struct i40iw_aeq_ops iw_aeq_ops = {
|
||||
.aeq_init = i40iw_sc_aeq_init,
|
||||
.aeq_create = i40iw_sc_aeq_create,
|
||||
.aeq_destroy = i40iw_sc_aeq_destroy,
|
||||
@@ -5137,11 +5088,11 @@ static struct i40iw_aeq_ops iw_aeq_ops = {
|
||||
};
|
||||
|
||||
/* iwarp pd ops */
|
||||
static struct i40iw_pd_ops iw_pd_ops = {
|
||||
static const struct i40iw_pd_ops iw_pd_ops = {
|
||||
.pd_init = i40iw_sc_pd_init,
|
||||
};
|
||||
|
||||
static struct i40iw_priv_qp_ops iw_priv_qp_ops = {
|
||||
static const struct i40iw_priv_qp_ops iw_priv_qp_ops = {
|
||||
.qp_init = i40iw_sc_qp_init,
|
||||
.qp_create = i40iw_sc_qp_create,
|
||||
.qp_modify = i40iw_sc_qp_modify,
|
||||
@@ -5156,14 +5107,14 @@ static struct i40iw_priv_qp_ops iw_priv_qp_ops = {
|
||||
.iw_mr_fast_register = i40iw_sc_mr_fast_register
|
||||
};
|
||||
|
||||
static struct i40iw_priv_cq_ops iw_priv_cq_ops = {
|
||||
static const struct i40iw_priv_cq_ops iw_priv_cq_ops = {
|
||||
.cq_init = i40iw_sc_cq_init,
|
||||
.cq_create = i40iw_sc_cq_create,
|
||||
.cq_destroy = i40iw_sc_cq_destroy,
|
||||
.cq_modify = i40iw_sc_cq_modify,
|
||||
};
|
||||
|
||||
static struct i40iw_mr_ops iw_mr_ops = {
|
||||
static const struct i40iw_mr_ops iw_mr_ops = {
|
||||
.alloc_stag = i40iw_sc_alloc_stag,
|
||||
.mr_reg_non_shared = i40iw_sc_mr_reg_non_shared,
|
||||
.mr_reg_shared = i40iw_sc_mr_reg_shared,
|
||||
@@ -5172,8 +5123,7 @@ static struct i40iw_mr_ops iw_mr_ops = {
|
||||
.mw_alloc = i40iw_sc_mw_alloc
|
||||
};
|
||||
|
||||
static struct i40iw_cqp_misc_ops iw_cqp_misc_ops = {
|
||||
.manage_push_page = i40iw_sc_manage_push_page,
|
||||
static const struct i40iw_cqp_misc_ops iw_cqp_misc_ops = {
|
||||
.manage_hmc_pm_func_table = i40iw_sc_manage_hmc_pm_func_table,
|
||||
.set_hmc_resource_profile = i40iw_sc_set_hmc_resource_profile,
|
||||
.commit_fpm_values = i40iw_sc_commit_fpm_values,
|
||||
@@ -5195,7 +5145,7 @@ static struct i40iw_cqp_misc_ops iw_cqp_misc_ops = {
|
||||
.update_resume_qp = i40iw_sc_resume_qp
|
||||
};
|
||||
|
||||
static struct i40iw_hmc_ops iw_hmc_ops = {
|
||||
static const struct i40iw_hmc_ops iw_hmc_ops = {
|
||||
.init_iw_hmc = i40iw_sc_init_iw_hmc,
|
||||
.parse_fpm_query_buf = i40iw_sc_parse_fpm_query_buf,
|
||||
.configure_iw_fpm = i40iw_sc_configure_iw_fpm,
|
||||
|
||||
@@ -40,11 +40,6 @@
|
||||
#define I40IW_DB_ADDR_OFFSET (4 * 1024 * 1024 - 64 * 1024)
|
||||
#define I40IW_VF_DB_ADDR_OFFSET (64 * 1024)
|
||||
|
||||
#define I40IW_PUSH_OFFSET (4 * 1024 * 1024)
|
||||
#define I40IW_PF_FIRST_PUSH_PAGE_INDEX 16
|
||||
#define I40IW_VF_PUSH_OFFSET ((8 + 64) * 1024)
|
||||
#define I40IW_VF_FIRST_PUSH_PAGE_INDEX 2
|
||||
|
||||
#define I40IW_PE_DB_SIZE_4M 1
|
||||
#define I40IW_PE_DB_SIZE_8M 2
|
||||
|
||||
@@ -402,7 +397,6 @@
|
||||
#define I40IW_CQP_OP_MANAGE_LOC_MAC_IP_TABLE 0x0e
|
||||
#define I40IW_CQP_OP_MANAGE_ARP 0x0f
|
||||
#define I40IW_CQP_OP_MANAGE_VF_PBLE_BP 0x10
|
||||
#define I40IW_CQP_OP_MANAGE_PUSH_PAGES 0x11
|
||||
#define I40IW_CQP_OP_QUERY_RDMA_FEATURES 0x12
|
||||
#define I40IW_CQP_OP_UPLOAD_CONTEXT 0x13
|
||||
#define I40IW_CQP_OP_ALLOCATE_LOC_MAC_IP_TABLE_ENTRY 0x14
|
||||
@@ -843,7 +837,6 @@
|
||||
#define I40IW_CQPSQ_MVPBP_PD_PLPBA_MASK \
|
||||
(0x1fffffffffffffffULL << I40IW_CQPSQ_MVPBP_PD_PLPBA_SHIFT)
|
||||
|
||||
/* Manage Push Page - MPP */
|
||||
#define I40IW_INVALID_PUSH_PAGE_INDEX 0xffff
|
||||
|
||||
#define I40IW_CQPSQ_MPP_QS_HANDLE_SHIFT 0
|
||||
@@ -1352,9 +1345,6 @@
|
||||
#define I40IWQPSQ_ADDFRAGCNT_SHIFT 38
|
||||
#define I40IWQPSQ_ADDFRAGCNT_MASK (0x7ULL << I40IWQPSQ_ADDFRAGCNT_SHIFT)
|
||||
|
||||
#define I40IWQPSQ_PUSHWQE_SHIFT 56
|
||||
#define I40IWQPSQ_PUSHWQE_MASK (1ULL << I40IWQPSQ_PUSHWQE_SHIFT)
|
||||
|
||||
#define I40IWQPSQ_STREAMMODE_SHIFT 58
|
||||
#define I40IWQPSQ_STREAMMODE_MASK (1ULL << I40IWQPSQ_STREAMMODE_SHIFT)
|
||||
|
||||
@@ -1740,18 +1730,17 @@ enum i40iw_alignment {
|
||||
#define OP_MW_ALLOC 20
|
||||
#define OP_QP_FLUSH_WQES 21
|
||||
#define OP_ADD_ARP_CACHE_ENTRY 22
|
||||
#define OP_MANAGE_PUSH_PAGE 23
|
||||
#define OP_UPDATE_PE_SDS 24
|
||||
#define OP_MANAGE_HMC_PM_FUNC_TABLE 25
|
||||
#define OP_SUSPEND 26
|
||||
#define OP_RESUME 27
|
||||
#define OP_MANAGE_VF_PBLE_BP 28
|
||||
#define OP_QUERY_FPM_VALUES 29
|
||||
#define OP_COMMIT_FPM_VALUES 30
|
||||
#define OP_REQUESTED_COMMANDS 31
|
||||
#define OP_COMPLETED_COMMANDS 32
|
||||
#define OP_GEN_AE 33
|
||||
#define OP_QUERY_RDMA_FEATURES 34
|
||||
#define OP_SIZE_CQP_STAT_ARRAY 35
|
||||
#define OP_UPDATE_PE_SDS 23
|
||||
#define OP_MANAGE_HMC_PM_FUNC_TABLE 24
|
||||
#define OP_SUSPEND 25
|
||||
#define OP_RESUME 26
|
||||
#define OP_MANAGE_VF_PBLE_BP 27
|
||||
#define OP_QUERY_FPM_VALUES 28
|
||||
#define OP_COMMIT_FPM_VALUES 29
|
||||
#define OP_REQUESTED_COMMANDS 30
|
||||
#define OP_COMPLETED_COMMANDS 31
|
||||
#define OP_GEN_AE 32
|
||||
#define OP_QUERY_RDMA_FEATURES 33
|
||||
#define OP_SIZE_CQP_STAT_ARRAY 34
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,6 @@ enum i40iw_status_code {
|
||||
I40IW_ERR_QUEUE_EMPTY = -22,
|
||||
I40IW_ERR_INVALID_ALIGNMENT = -23,
|
||||
I40IW_ERR_FLUSHED_QUEUE = -24,
|
||||
I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25,
|
||||
I40IW_ERR_INVALID_INLINE_DATA_SIZE = -26,
|
||||
I40IW_ERR_TIMEOUT = -27,
|
||||
I40IW_ERR_OPCODE_MISMATCH = -28,
|
||||
|
||||
@@ -387,7 +387,6 @@ struct i40iw_sc_qp {
|
||||
u8 *q2_buf;
|
||||
u64 qp_compl_ctx;
|
||||
u16 qs_handle;
|
||||
u16 push_idx;
|
||||
u8 sq_tph_val;
|
||||
u8 rq_tph_val;
|
||||
u8 qp_state;
|
||||
@@ -493,16 +492,16 @@ struct i40iw_sc_dev {
|
||||
struct i40iw_sc_aeq *aeq;
|
||||
struct i40iw_sc_ceq *ceq[I40IW_CEQ_MAX_COUNT];
|
||||
struct i40iw_sc_cq *ccq;
|
||||
struct i40iw_cqp_ops *cqp_ops;
|
||||
struct i40iw_ccq_ops *ccq_ops;
|
||||
struct i40iw_ceq_ops *ceq_ops;
|
||||
struct i40iw_aeq_ops *aeq_ops;
|
||||
struct i40iw_pd_ops *iw_pd_ops;
|
||||
struct i40iw_priv_qp_ops *iw_priv_qp_ops;
|
||||
struct i40iw_priv_cq_ops *iw_priv_cq_ops;
|
||||
struct i40iw_mr_ops *mr_ops;
|
||||
struct i40iw_cqp_misc_ops *cqp_misc_ops;
|
||||
struct i40iw_hmc_ops *hmc_ops;
|
||||
const struct i40iw_cqp_ops *cqp_ops;
|
||||
const struct i40iw_ccq_ops *ccq_ops;
|
||||
const struct i40iw_ceq_ops *ceq_ops;
|
||||
const struct i40iw_aeq_ops *aeq_ops;
|
||||
const struct i40iw_pd_ops *iw_pd_ops;
|
||||
const struct i40iw_priv_qp_ops *iw_priv_qp_ops;
|
||||
const struct i40iw_priv_cq_ops *iw_priv_cq_ops;
|
||||
const struct i40iw_mr_ops *mr_ops;
|
||||
const struct i40iw_cqp_misc_ops *cqp_misc_ops;
|
||||
const struct i40iw_hmc_ops *hmc_ops;
|
||||
struct i40iw_vchnl_if vchnl_if;
|
||||
const struct i40iw_vf_cqp_ops *iw_vf_cqp_ops;
|
||||
|
||||
@@ -749,8 +748,6 @@ struct i40iw_qp_host_ctx_info {
|
||||
struct i40iwarp_offload_info *iwarp_info;
|
||||
u32 send_cq_num;
|
||||
u32 rcv_cq_num;
|
||||
u16 push_idx;
|
||||
bool push_mode_en;
|
||||
bool tcp_info_valid;
|
||||
bool iwarp_info_valid;
|
||||
bool err_rq_idx_valid;
|
||||
@@ -937,12 +934,6 @@ struct i40iw_local_mac_ipaddr_entry_info {
|
||||
u8 entry_idx;
|
||||
};
|
||||
|
||||
struct i40iw_cqp_manage_push_page_info {
|
||||
u32 push_idx;
|
||||
u16 qs_handle;
|
||||
u8 free_page;
|
||||
};
|
||||
|
||||
struct i40iw_qp_flush_info {
|
||||
u16 sq_minor_code;
|
||||
u16 sq_major_code;
|
||||
@@ -1114,9 +1105,6 @@ struct i40iw_mr_ops {
|
||||
};
|
||||
|
||||
struct i40iw_cqp_misc_ops {
|
||||
enum i40iw_status_code (*manage_push_page)(struct i40iw_sc_cqp *,
|
||||
struct i40iw_cqp_manage_push_page_info *,
|
||||
u64, bool);
|
||||
enum i40iw_status_code (*manage_hmc_pm_func_table)(struct i40iw_sc_cqp *,
|
||||
u64, u8, bool, bool);
|
||||
enum i40iw_status_code (*set_hmc_resource_profile)(struct i40iw_sc_cqp *,
|
||||
@@ -1253,12 +1241,6 @@ struct cqp_info {
|
||||
u64 scratch;
|
||||
} manage_vf_pble_bp;
|
||||
|
||||
struct {
|
||||
struct i40iw_sc_cqp *cqp;
|
||||
struct i40iw_cqp_manage_push_page_info info;
|
||||
u64 scratch;
|
||||
} manage_push_page;
|
||||
|
||||
struct {
|
||||
struct i40iw_sc_dev *dev;
|
||||
struct i40iw_upload_context_info info;
|
||||
|
||||
@@ -114,17 +114,6 @@ void i40iw_qp_post_wr(struct i40iw_qp_uk *qp)
|
||||
qp->initial_ring.head = qp->sq_ring.head;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_qp_ring_push_db - ring qp doorbell
|
||||
* @qp: hw qp ptr
|
||||
* @wqe_idx: wqe index
|
||||
*/
|
||||
static void i40iw_qp_ring_push_db(struct i40iw_qp_uk *qp, u32 wqe_idx)
|
||||
{
|
||||
set_32bit_val(qp->push_db, 0, LS_32((wqe_idx >> 2), I40E_PFPE_WQEALLOC_WQE_DESC_INDEX) | qp->qp_id);
|
||||
qp->initial_ring.head = I40IW_RING_GETCURRENT_HEAD(qp->sq_ring);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_qp_get_next_send_wqe - return next wqe ptr
|
||||
* @qp: hw qp ptr
|
||||
@@ -426,7 +415,6 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
|
||||
u64 *wqe;
|
||||
u8 *dest, *src;
|
||||
struct i40iw_inline_rdma_write *op_info;
|
||||
u64 *push;
|
||||
u64 header = 0;
|
||||
u32 wqe_idx;
|
||||
enum i40iw_status_code ret_code;
|
||||
@@ -453,7 +441,6 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
|
||||
LS_64(I40IWQP_OP_RDMA_WRITE, I40IWQPSQ_OPCODE) |
|
||||
LS_64(op_info->len, I40IWQPSQ_INLINEDATALEN) |
|
||||
LS_64(1, I40IWQPSQ_INLINEDATAFLAG) |
|
||||
LS_64((qp->push_db ? 1 : 0), I40IWQPSQ_PUSHWQE) |
|
||||
LS_64(read_fence, I40IWQPSQ_READFENCE) |
|
||||
LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) |
|
||||
LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) |
|
||||
@@ -475,14 +462,8 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
|
||||
|
||||
set_64bit_val(wqe, 24, header);
|
||||
|
||||
if (qp->push_db) {
|
||||
push = (u64 *)((uintptr_t)qp->push_wqe + (wqe_idx & 0x3) * 0x20);
|
||||
memcpy(push, wqe, (op_info->len > 16) ? op_info->len + 16 : 32);
|
||||
i40iw_qp_ring_push_db(qp, wqe_idx);
|
||||
} else {
|
||||
if (post_sq)
|
||||
i40iw_qp_post_wr(qp);
|
||||
}
|
||||
if (post_sq)
|
||||
i40iw_qp_post_wr(qp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -507,7 +488,6 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
|
||||
enum i40iw_status_code ret_code;
|
||||
bool read_fence = false;
|
||||
u8 wqe_size;
|
||||
u64 *push;
|
||||
|
||||
op_info = &info->op.inline_send;
|
||||
if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
|
||||
@@ -526,7 +506,6 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
|
||||
LS_64(info->op_type, I40IWQPSQ_OPCODE) |
|
||||
LS_64(op_info->len, I40IWQPSQ_INLINEDATALEN) |
|
||||
LS_64(1, I40IWQPSQ_INLINEDATAFLAG) |
|
||||
LS_64((qp->push_db ? 1 : 0), I40IWQPSQ_PUSHWQE) |
|
||||
LS_64(read_fence, I40IWQPSQ_READFENCE) |
|
||||
LS_64(info->local_fence, I40IWQPSQ_LOCALFENCE) |
|
||||
LS_64(info->signaled, I40IWQPSQ_SIGCOMPL) |
|
||||
@@ -548,14 +527,8 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
|
||||
|
||||
set_64bit_val(wqe, 24, header);
|
||||
|
||||
if (qp->push_db) {
|
||||
push = (u64 *)((uintptr_t)qp->push_wqe + (wqe_idx & 0x3) * 0x20);
|
||||
memcpy(push, wqe, (op_info->len > 16) ? op_info->len + 16 : 32);
|
||||
i40iw_qp_ring_push_db(qp, wqe_idx);
|
||||
} else {
|
||||
if (post_sq)
|
||||
i40iw_qp_post_wr(qp);
|
||||
}
|
||||
if (post_sq)
|
||||
i40iw_qp_post_wr(qp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -772,7 +745,6 @@ static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq,
|
||||
|
||||
q_type = (u8)RS_64(qword3, I40IW_CQ_SQ);
|
||||
info->error = (bool)RS_64(qword3, I40IW_CQ_ERROR);
|
||||
info->push_dropped = (bool)RS_64(qword3, I40IWCQ_PSHDROP);
|
||||
if (info->error) {
|
||||
info->comp_status = I40IW_COMPL_STATUS_FLUSHED;
|
||||
info->major_err = (bool)RS_64(qword3, I40IW_CQ_MAJERR);
|
||||
@@ -951,7 +923,6 @@ enum i40iw_status_code i40iw_get_rqdepth(u32 rq_size, u8 shift, u32 *rqdepth)
|
||||
|
||||
static const struct i40iw_qp_uk_ops iw_qp_uk_ops = {
|
||||
.iw_qp_post_wr = i40iw_qp_post_wr,
|
||||
.iw_qp_ring_push_db = i40iw_qp_ring_push_db,
|
||||
.iw_rdma_write = i40iw_rdma_write,
|
||||
.iw_rdma_read = i40iw_rdma_read,
|
||||
.iw_send = i40iw_send,
|
||||
@@ -1009,11 +980,7 @@ enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp,
|
||||
|
||||
qp->wqe_alloc_reg = info->wqe_alloc_reg;
|
||||
qp->qp_id = info->qp_id;
|
||||
|
||||
qp->sq_size = info->sq_size;
|
||||
qp->push_db = info->push_db;
|
||||
qp->push_wqe = info->push_wqe;
|
||||
|
||||
qp->max_sq_frag_cnt = info->max_sq_frag_cnt;
|
||||
sq_ring_size = qp->sq_size << sqshift;
|
||||
|
||||
|
||||
@@ -64,13 +64,11 @@ enum i40iw_device_capabilities_const {
|
||||
I40IW_MAX_SGE_RD = 1,
|
||||
I40IW_MAX_OUTBOUND_MESSAGE_SIZE = 2147483647,
|
||||
I40IW_MAX_INBOUND_MESSAGE_SIZE = 2147483647,
|
||||
I40IW_MAX_PUSH_PAGE_COUNT = 4096,
|
||||
I40IW_MAX_PE_ENABLED_VF_COUNT = 32,
|
||||
I40IW_MAX_VF_FPM_ID = 47,
|
||||
I40IW_MAX_VF_PER_PF = 127,
|
||||
I40IW_MAX_SQ_PAYLOAD_SIZE = 2145386496,
|
||||
I40IW_MAX_INLINE_DATA_SIZE = 48,
|
||||
I40IW_MAX_PUSHMODE_INLINE_DATA_SIZE = 48,
|
||||
I40IW_MAX_IRD_SIZE = 64,
|
||||
I40IW_MAX_ORD_SIZE = 127,
|
||||
I40IW_MAX_WQ_ENTRIES = 2048,
|
||||
@@ -272,7 +270,6 @@ struct i40iw_cq_poll_info {
|
||||
u16 minor_err;
|
||||
u8 op_type;
|
||||
bool stag_invalid_set;
|
||||
bool push_dropped;
|
||||
bool error;
|
||||
bool is_srq;
|
||||
bool solicited_event;
|
||||
@@ -280,7 +277,6 @@ struct i40iw_cq_poll_info {
|
||||
|
||||
struct i40iw_qp_uk_ops {
|
||||
void (*iw_qp_post_wr)(struct i40iw_qp_uk *);
|
||||
void (*iw_qp_ring_push_db)(struct i40iw_qp_uk *, u32);
|
||||
enum i40iw_status_code (*iw_rdma_write)(struct i40iw_qp_uk *,
|
||||
struct i40iw_post_sq_info *, bool);
|
||||
enum i40iw_status_code (*iw_rdma_read)(struct i40iw_qp_uk *,
|
||||
@@ -340,8 +336,6 @@ struct i40iw_qp_uk {
|
||||
struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
|
||||
u64 *rq_wrid_array;
|
||||
u64 *shadow_area;
|
||||
u32 *push_db;
|
||||
u64 *push_wqe;
|
||||
struct i40iw_ring sq_ring;
|
||||
struct i40iw_ring rq_ring;
|
||||
struct i40iw_ring initial_ring;
|
||||
@@ -381,8 +375,6 @@ struct i40iw_qp_uk_init_info {
|
||||
u64 *shadow_area;
|
||||
struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
|
||||
u64 *rq_wrid_array;
|
||||
u32 *push_db;
|
||||
u64 *push_wqe;
|
||||
u32 qp_id;
|
||||
u32 sq_size;
|
||||
u32 rq_size;
|
||||
|
||||
@@ -179,78 +179,6 @@ static int i40iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
|
||||
pgprot_noncached(vma->vm_page_prot), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_alloc_push_page - allocate a push page for qp
|
||||
* @iwdev: iwarp device
|
||||
* @qp: hardware control qp
|
||||
*/
|
||||
static void i40iw_alloc_push_page(struct i40iw_device *iwdev, struct i40iw_sc_qp *qp)
|
||||
{
|
||||
struct i40iw_cqp_request *cqp_request;
|
||||
struct cqp_commands_info *cqp_info;
|
||||
enum i40iw_status_code status;
|
||||
|
||||
if (qp->push_idx != I40IW_INVALID_PUSH_PAGE_INDEX)
|
||||
return;
|
||||
|
||||
cqp_request = i40iw_get_cqp_request(&iwdev->cqp, true);
|
||||
if (!cqp_request)
|
||||
return;
|
||||
|
||||
atomic_inc(&cqp_request->refcount);
|
||||
|
||||
cqp_info = &cqp_request->info;
|
||||
cqp_info->cqp_cmd = OP_MANAGE_PUSH_PAGE;
|
||||
cqp_info->post_sq = 1;
|
||||
|
||||
cqp_info->in.u.manage_push_page.info.qs_handle = qp->qs_handle;
|
||||
cqp_info->in.u.manage_push_page.info.free_page = 0;
|
||||
cqp_info->in.u.manage_push_page.cqp = &iwdev->cqp.sc_cqp;
|
||||
cqp_info->in.u.manage_push_page.scratch = (uintptr_t)cqp_request;
|
||||
|
||||
status = i40iw_handle_cqp_op(iwdev, cqp_request);
|
||||
if (!status)
|
||||
qp->push_idx = cqp_request->compl_info.op_ret_val;
|
||||
else
|
||||
i40iw_pr_err("CQP-OP Push page fail");
|
||||
i40iw_put_cqp_request(&iwdev->cqp, cqp_request);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_dealloc_push_page - free a push page for qp
|
||||
* @iwdev: iwarp device
|
||||
* @qp: hardware control qp
|
||||
*/
|
||||
static void i40iw_dealloc_push_page(struct i40iw_device *iwdev, struct i40iw_sc_qp *qp)
|
||||
{
|
||||
struct i40iw_cqp_request *cqp_request;
|
||||
struct cqp_commands_info *cqp_info;
|
||||
enum i40iw_status_code status;
|
||||
|
||||
if (qp->push_idx == I40IW_INVALID_PUSH_PAGE_INDEX)
|
||||
return;
|
||||
|
||||
cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
|
||||
if (!cqp_request)
|
||||
return;
|
||||
|
||||
cqp_info = &cqp_request->info;
|
||||
cqp_info->cqp_cmd = OP_MANAGE_PUSH_PAGE;
|
||||
cqp_info->post_sq = 1;
|
||||
|
||||
cqp_info->in.u.manage_push_page.info.push_idx = qp->push_idx;
|
||||
cqp_info->in.u.manage_push_page.info.qs_handle = qp->qs_handle;
|
||||
cqp_info->in.u.manage_push_page.info.free_page = 1;
|
||||
cqp_info->in.u.manage_push_page.cqp = &iwdev->cqp.sc_cqp;
|
||||
cqp_info->in.u.manage_push_page.scratch = (uintptr_t)cqp_request;
|
||||
|
||||
status = i40iw_handle_cqp_op(iwdev, cqp_request);
|
||||
if (!status)
|
||||
qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
|
||||
else
|
||||
i40iw_pr_err("CQP-OP Push page fail");
|
||||
}
|
||||
|
||||
/**
|
||||
* i40iw_alloc_pd - allocate protection domain
|
||||
* @pd: PD pointer
|
||||
@@ -348,7 +276,6 @@ void i40iw_free_qp_resources(struct i40iw_qp *iwqp)
|
||||
u32 qp_num = iwqp->ibqp.qp_num;
|
||||
|
||||
i40iw_ieq_cleanup_qp(iwdev->vsi.ieq, &iwqp->sc_qp);
|
||||
i40iw_dealloc_push_page(iwdev, &iwqp->sc_qp);
|
||||
if (qp_num)
|
||||
i40iw_free_resource(iwdev, iwdev->allocated_qps, qp_num);
|
||||
if (iwpbl->pbl_allocated)
|
||||
@@ -533,7 +460,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (init_attr->create_flags)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
if (init_attr->cap.max_inline_data > I40IW_MAX_INLINE_DATA_SIZE)
|
||||
init_attr->cap.max_inline_data = I40IW_MAX_INLINE_DATA_SIZE;
|
||||
|
||||
@@ -561,8 +488,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
|
||||
|
||||
qp = &iwqp->sc_qp;
|
||||
qp->back_qp = (void *)iwqp;
|
||||
qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
|
||||
|
||||
iwqp->iwdev = iwdev;
|
||||
iwqp->ctx_info.iwarp_info = &iwqp->iwarp_info;
|
||||
|
||||
@@ -606,8 +531,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
|
||||
err_code = -EOPNOTSUPP;
|
||||
goto error;
|
||||
}
|
||||
if (iwdev->push_mode)
|
||||
i40iw_alloc_push_page(iwdev, qp);
|
||||
if (udata) {
|
||||
err_code = ib_copy_from_udata(&req, udata, sizeof(req));
|
||||
if (err_code) {
|
||||
@@ -666,13 +589,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
|
||||
ctx_info->iwarp_info_valid = true;
|
||||
ctx_info->send_cq_num = iwqp->iwscq->sc_cq.cq_uk.cq_id;
|
||||
ctx_info->rcv_cq_num = iwqp->iwrcq->sc_cq.cq_uk.cq_id;
|
||||
if (qp->push_idx == I40IW_INVALID_PUSH_PAGE_INDEX) {
|
||||
ctx_info->push_mode_en = false;
|
||||
} else {
|
||||
ctx_info->push_mode_en = true;
|
||||
ctx_info->push_idx = qp->push_idx;
|
||||
}
|
||||
|
||||
ret = dev->iw_priv_qp_ops->qp_setctx(&iwqp->sc_qp,
|
||||
(u64 *)iwqp->host_ctx.va,
|
||||
ctx_info);
|
||||
@@ -712,7 +628,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
|
||||
uresp.actual_sq_size = sq_size;
|
||||
uresp.actual_rq_size = rq_size;
|
||||
uresp.qp_id = qp_num;
|
||||
uresp.push_idx = qp->push_idx;
|
||||
uresp.push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
|
||||
err_code = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
if (err_code) {
|
||||
i40iw_pr_err("copy_to_udata failed\n");
|
||||
@@ -832,6 +748,9 @@ int i40iw_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
u32 err;
|
||||
unsigned long flags;
|
||||
|
||||
if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
ctx_info = &iwqp->ctx_info;
|
||||
iwarp_info = &iwqp->iwarp_info;
|
||||
@@ -1081,6 +1000,9 @@ static int i40iw_create_cq(struct ib_cq *ibcq,
|
||||
int err_code;
|
||||
int entries = attr->cqe;
|
||||
|
||||
if (attr->flags)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (iwdev->closing)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -2033,7 +1955,7 @@ static ssize_t hw_rev_show(struct device *dev,
|
||||
rdma_device_to_drv_device(dev, struct i40iw_ib_device, ibdev);
|
||||
u32 hw_rev = iwibdev->iwdev->sc_dev.hw_rev;
|
||||
|
||||
return sprintf(buf, "%x\n", hw_rev);
|
||||
return sysfs_emit(buf, "%x\n", hw_rev);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -2043,7 +1965,7 @@ static DEVICE_ATTR_RO(hw_rev);
|
||||
static ssize_t hca_type_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "I40IW\n");
|
||||
return sysfs_emit(buf, "I40IW\n");
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -2053,7 +1975,7 @@ static DEVICE_ATTR_RO(hca_type);
|
||||
static ssize_t board_id_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%.*s\n", 32, "I40IW Board ID");
|
||||
return sysfs_emit(buf, "%.*s\n", 32, "I40IW Board ID");
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -2661,27 +2583,6 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
|
||||
iwibdev->ibdev.node_type = RDMA_NODE_RNIC;
|
||||
ether_addr_copy((u8 *)&iwibdev->ibdev.node_guid, netdev->dev_addr);
|
||||
|
||||
iwibdev->ibdev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_REQ_NOTIFY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_POLL_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_POST_RECV) |
|
||||
(1ull << IB_USER_VERBS_CMD_POST_SEND);
|
||||
iwibdev->ibdev.phys_port_cnt = 1;
|
||||
iwibdev->ibdev.num_comp_vectors = iwdev->ceqs_count;
|
||||
iwibdev->ibdev.dev.parent = &pcidev->dev;
|
||||
|
||||
@@ -1523,6 +1523,7 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
|
||||
return;
|
||||
} else
|
||||
*slave_id = slave;
|
||||
break;
|
||||
default:
|
||||
/* nothing */;
|
||||
}
|
||||
|
||||
@@ -2024,7 +2024,8 @@ static ssize_t hca_type_show(struct device *device,
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
return sprintf(buf, "MT%d\n", dev->dev->persist->pdev->device);
|
||||
|
||||
return sysfs_emit(buf, "MT%d\n", dev->dev->persist->pdev->device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -2033,7 +2034,8 @@ static ssize_t hw_rev_show(struct device *device,
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
return sprintf(buf, "%x\n", dev->dev->rev_id);
|
||||
|
||||
return sysfs_emit(buf, "%x\n", dev->dev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -2043,8 +2045,7 @@ static ssize_t board_id_show(struct device *device,
|
||||
struct mlx4_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN,
|
||||
dev->dev->board_id);
|
||||
return sysfs_emit(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -2264,10 +2265,7 @@ static void mlx4_ib_update_qps(struct mlx4_ib_dev *ibdev,
|
||||
u64 release_mac = MLX4_IB_INVALID_MAC;
|
||||
struct mlx4_ib_qp *qp;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
new_smac = mlx4_mac_to_u64(dev->dev_addr);
|
||||
read_unlock(&dev_base_lock);
|
||||
|
||||
atomic64_set(&ibdev->iboe.mac[port - 1], new_smac);
|
||||
|
||||
/* no need for update QP1 and mac registration in non-SRIOV */
|
||||
@@ -2657,73 +2655,25 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
|
||||
ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
|
||||
ibdev->ib_dev.dev.parent = &dev->persist->pdev->dev;
|
||||
|
||||
ibdev->ib_dev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_REREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
|
||||
(1ull << IB_USER_VERBS_CMD_DETACH_MCAST) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_OPEN_QP);
|
||||
|
||||
ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_ops);
|
||||
ibdev->ib_dev.uverbs_ex_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_CQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_QP);
|
||||
|
||||
if ((dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) &&
|
||||
((mlx4_ib_port_link_layer(&ibdev->ib_dev, 1) ==
|
||||
IB_LINK_LAYER_ETHERNET) ||
|
||||
(mlx4_ib_port_link_layer(&ibdev->ib_dev, 2) ==
|
||||
IB_LINK_LAYER_ETHERNET))) {
|
||||
ibdev->ib_dev.uverbs_ex_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL);
|
||||
IB_LINK_LAYER_ETHERNET)))
|
||||
ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_wq_ops);
|
||||
}
|
||||
|
||||
if (dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW ||
|
||||
dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN) {
|
||||
ibdev->ib_dev.uverbs_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_MW) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_MW);
|
||||
dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN)
|
||||
ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_mw_ops);
|
||||
}
|
||||
|
||||
if (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) {
|
||||
ibdev->ib_dev.uverbs_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_CMD_OPEN_XRCD) |
|
||||
(1ull << IB_USER_VERBS_CMD_CLOSE_XRCD);
|
||||
ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_xrc_ops);
|
||||
}
|
||||
|
||||
if (check_flow_steering_support(dev)) {
|
||||
ibdev->steering_support = MLX4_STEERING_MODE_DEVICE_MANAGED;
|
||||
ibdev->ib_dev.uverbs_ex_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW);
|
||||
ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_fs_ops);
|
||||
}
|
||||
|
||||
|
||||
@@ -988,53 +988,63 @@ int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port,
|
||||
}
|
||||
|
||||
static ssize_t sysfs_show_group(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mcast_group *group =
|
||||
container_of(attr, struct mcast_group, dentry);
|
||||
struct mcast_req *req = NULL;
|
||||
char pending_str[40];
|
||||
char state_str[40];
|
||||
ssize_t len = 0;
|
||||
int f;
|
||||
char pending_str[40];
|
||||
int len;
|
||||
int i;
|
||||
u32 hoplimit;
|
||||
|
||||
if (group->state == MCAST_IDLE)
|
||||
sprintf(state_str, "%s", get_state_string(group->state));
|
||||
scnprintf(state_str, sizeof(state_str), "%s",
|
||||
get_state_string(group->state));
|
||||
else
|
||||
sprintf(state_str, "%s(TID=0x%llx)",
|
||||
get_state_string(group->state),
|
||||
be64_to_cpu(group->last_req_tid));
|
||||
if (list_empty(&group->pending_list)) {
|
||||
sprintf(pending_str, "No");
|
||||
} else {
|
||||
req = list_first_entry(&group->pending_list, struct mcast_req, group_list);
|
||||
sprintf(pending_str, "Yes(TID=0x%llx)",
|
||||
be64_to_cpu(req->sa_mad.mad_hdr.tid));
|
||||
}
|
||||
len += sprintf(buf + len, "%1d [%02d,%02d,%02d] %4d %4s %5s ",
|
||||
group->rec.scope_join_state & 0xf,
|
||||
group->members[2], group->members[1], group->members[0],
|
||||
atomic_read(&group->refcount),
|
||||
pending_str,
|
||||
state_str);
|
||||
for (f = 0; f < MAX_VFS; ++f)
|
||||
if (group->func[f].state == MCAST_MEMBER)
|
||||
len += sprintf(buf + len, "%d[%1x] ",
|
||||
f, group->func[f].join_state);
|
||||
scnprintf(state_str, sizeof(state_str), "%s(TID=0x%llx)",
|
||||
get_state_string(group->state),
|
||||
be64_to_cpu(group->last_req_tid));
|
||||
|
||||
len += sprintf(buf + len, "\t\t(%4hx %4x %2x %2x %2x %2x %2x "
|
||||
"%4x %4x %2x %2x)\n",
|
||||
be16_to_cpu(group->rec.pkey),
|
||||
be32_to_cpu(group->rec.qkey),
|
||||
(group->rec.mtusel_mtu & 0xc0) >> 6,
|
||||
group->rec.mtusel_mtu & 0x3f,
|
||||
group->rec.tclass,
|
||||
(group->rec.ratesel_rate & 0xc0) >> 6,
|
||||
group->rec.ratesel_rate & 0x3f,
|
||||
(be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0xf0000000) >> 28,
|
||||
(be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0x0fffff00) >> 8,
|
||||
be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0x000000ff,
|
||||
group->rec.proxy_join);
|
||||
if (list_empty(&group->pending_list)) {
|
||||
scnprintf(pending_str, sizeof(pending_str), "No");
|
||||
} else {
|
||||
req = list_first_entry(&group->pending_list, struct mcast_req,
|
||||
group_list);
|
||||
scnprintf(pending_str, sizeof(pending_str), "Yes(TID=0x%llx)",
|
||||
be64_to_cpu(req->sa_mad.mad_hdr.tid));
|
||||
}
|
||||
|
||||
len = sysfs_emit(buf, "%1d [%02d,%02d,%02d] %4d %4s %5s ",
|
||||
group->rec.scope_join_state & 0xf,
|
||||
group->members[2],
|
||||
group->members[1],
|
||||
group->members[0],
|
||||
atomic_read(&group->refcount),
|
||||
pending_str,
|
||||
state_str);
|
||||
|
||||
for (i = 0; i < MAX_VFS; i++) {
|
||||
if (group->func[i].state == MCAST_MEMBER)
|
||||
len += sysfs_emit_at(buf, len, "%d[%1x] ", i,
|
||||
group->func[i].join_state);
|
||||
}
|
||||
|
||||
hoplimit = be32_to_cpu(group->rec.sl_flowlabel_hoplimit);
|
||||
len += sysfs_emit_at(buf, len,
|
||||
"\t\t(%4hx %4x %2x %2x %2x %2x %2x %4x %4x %2x %2x)\n",
|
||||
be16_to_cpu(group->rec.pkey),
|
||||
be32_to_cpu(group->rec.qkey),
|
||||
(group->rec.mtusel_mtu & 0xc0) >> 6,
|
||||
(group->rec.mtusel_mtu & 0x3f),
|
||||
group->rec.tclass,
|
||||
(group->rec.ratesel_rate & 0xc0) >> 6,
|
||||
(group->rec.ratesel_rate & 0x3f),
|
||||
(hoplimit & 0xf0000000) >> 28,
|
||||
(hoplimit & 0x0fffff00) >> 8,
|
||||
(hoplimit & 0x000000ff),
|
||||
group->rec.proxy_join);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -908,10 +908,10 @@ int mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn);
|
||||
void mlx4_ib_steer_qp_free(struct mlx4_ib_dev *dev, u32 qpn, int count);
|
||||
int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
|
||||
int is_attach);
|
||||
int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
|
||||
u64 start, u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata);
|
||||
int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
|
||||
const struct ib_gid_attr *attr);
|
||||
|
||||
|
||||
@@ -456,10 +456,10 @@ err_free:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
|
||||
u64 start, u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata)
|
||||
struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int mr_access_flags, struct ib_pd *pd,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mlx4_ib_dev *dev = to_mdev(mr->device);
|
||||
struct mlx4_ib_mr *mmr = to_mmr(mr);
|
||||
@@ -472,9 +472,8 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
|
||||
* race exists.
|
||||
*/
|
||||
err = mlx4_mr_hw_get_mpt(dev->dev, &mmr->mmr, &pmpt_entry);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
return ERR_PTR(err);
|
||||
|
||||
if (flags & IB_MR_REREG_PD) {
|
||||
err = mlx4_mr_hw_change_pd(dev->dev, *pmpt_entry,
|
||||
@@ -542,8 +541,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
|
||||
|
||||
release_mpt_entry:
|
||||
mlx4_mr_hw_put_mpt(dev->dev, pmpt_entry);
|
||||
|
||||
return err;
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -1493,7 +1493,7 @@ static int _mlx4_ib_create_qp(struct ib_pd *pd, struct mlx4_ib_qp *qp,
|
||||
MLX4_IB_SRIOV_SQP |
|
||||
MLX4_IB_QP_NETIF |
|
||||
MLX4_IB_QP_CREATE_ROCE_V2_GSI))
|
||||
return -EINVAL;
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) {
|
||||
if (init_attr->qp_type != IB_QPT_UD)
|
||||
@@ -1561,6 +1561,11 @@ static int _mlx4_ib_create_qp(struct ib_pd *pd, struct mlx4_ib_qp *qp,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (init_attr->create_flags &
|
||||
(MLX4_IB_SRIOV_SQP | MLX4_IB_SRIOV_TUNNEL_QP))
|
||||
/* Internal QP created with ib_create_qp */
|
||||
rdma_restrack_no_track(&qp->ibqp.res);
|
||||
|
||||
qp->port = init_attr->port_num;
|
||||
qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 :
|
||||
init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI ? sqpn : 1;
|
||||
@@ -2787,6 +2792,9 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
struct mlx4_ib_qp *mqp = to_mqp(ibqp);
|
||||
int ret;
|
||||
|
||||
if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = _mlx4_ib_modify_qp(ibqp, attr, attr_mask, udata);
|
||||
|
||||
if (mqp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI) {
|
||||
@@ -4007,7 +4015,9 @@ int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr
|
||||
qp_attr->qp_access_flags =
|
||||
to_ib_qp_access_flags(be32_to_cpu(context.params2));
|
||||
|
||||
if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) {
|
||||
if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC ||
|
||||
qp->ibqp.qp_type == IB_QPT_XRC_INI ||
|
||||
qp->ibqp.qp_type == IB_QPT_XRC_TGT) {
|
||||
to_rdma_ah_attr(dev, &qp_attr->ah_attr, &context.pri_path);
|
||||
to_rdma_ah_attr(dev, &qp_attr->alt_ah_attr, &context.alt_path);
|
||||
qp_attr->alt_pkey_index = context.alt_path.pkey_index & 0x7f;
|
||||
|
||||
@@ -86,6 +86,10 @@ int mlx4_ib_create_srq(struct ib_srq *ib_srq,
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (init_attr->srq_type != IB_SRQT_BASIC &&
|
||||
init_attr->srq_type != IB_SRQT_XRC)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Sanity check SRQ size before proceeding */
|
||||
if (init_attr->attr.max_wr >= dev->dev->caps.max_srq_wqes ||
|
||||
init_attr->attr.max_sge > dev->dev->caps.max_srq_sge)
|
||||
|
||||
@@ -56,7 +56,7 @@ static ssize_t show_admin_alias_guid(struct device *dev,
|
||||
mlx4_ib_iov_dentry->entry_num,
|
||||
port->num);
|
||||
|
||||
return sprintf(buf, "%llx\n", be64_to_cpu(sysadmin_ag_val));
|
||||
return sysfs_emit(buf, "%llx\n", be64_to_cpu(sysadmin_ag_val));
|
||||
}
|
||||
|
||||
/* store_admin_alias_guid stores the (new) administratively assigned value of that GUID.
|
||||
@@ -117,22 +117,24 @@ static ssize_t show_port_gid(struct device *dev,
|
||||
struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
|
||||
struct mlx4_ib_dev *mdev = port->dev;
|
||||
union ib_gid gid;
|
||||
ssize_t ret;
|
||||
int ret;
|
||||
__be16 *raw;
|
||||
|
||||
ret = __mlx4_ib_query_gid(&mdev->ib_dev, port->num,
|
||||
mlx4_ib_iov_dentry->entry_num, &gid, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(((__be16 *) gid.raw)[0]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[1]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[2]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[3]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[4]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[5]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[6]),
|
||||
be16_to_cpu(((__be16 *) gid.raw)[7]));
|
||||
return ret;
|
||||
|
||||
raw = (__be16 *)gid.raw;
|
||||
return sysfs_emit(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(raw[0]),
|
||||
be16_to_cpu(raw[1]),
|
||||
be16_to_cpu(raw[2]),
|
||||
be16_to_cpu(raw[3]),
|
||||
be16_to_cpu(raw[4]),
|
||||
be16_to_cpu(raw[5]),
|
||||
be16_to_cpu(raw[6]),
|
||||
be16_to_cpu(raw[7]));
|
||||
}
|
||||
|
||||
static ssize_t show_phys_port_pkey(struct device *dev,
|
||||
@@ -151,7 +153,7 @@ static ssize_t show_phys_port_pkey(struct device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "0x%04x\n", pkey);
|
||||
return sysfs_emit(buf, "0x%04x\n", pkey);
|
||||
}
|
||||
|
||||
#define DENTRY_REMOVE(_dentry) \
|
||||
@@ -441,16 +443,12 @@ static ssize_t show_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
|
||||
{
|
||||
struct port_table_attribute *tab_attr =
|
||||
container_of(attr, struct port_table_attribute, attr);
|
||||
ssize_t ret = -ENODEV;
|
||||
struct pkey_mgt *m = &p->dev->pkeys;
|
||||
u8 key = m->virt2phys_pkey[p->slave][p->port_num - 1][tab_attr->index];
|
||||
|
||||
if (p->dev->pkeys.virt2phys_pkey[p->slave][p->port_num - 1][tab_attr->index] >=
|
||||
(p->dev->dev->caps.pkey_table_len[p->port_num]))
|
||||
ret = sprintf(buf, "none\n");
|
||||
else
|
||||
ret = sprintf(buf, "%d\n",
|
||||
p->dev->pkeys.virt2phys_pkey[p->slave]
|
||||
[p->port_num - 1][tab_attr->index]);
|
||||
return ret;
|
||||
if (key >= p->dev->dev->caps.pkey_table_len[p->port_num])
|
||||
return sysfs_emit(buf, "none\n");
|
||||
return sysfs_emit(buf, "%d\n", key);
|
||||
}
|
||||
|
||||
static ssize_t store_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
|
||||
@@ -488,7 +486,7 @@ static ssize_t store_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
|
||||
static ssize_t show_port_gid_idx(struct mlx4_port *p,
|
||||
struct port_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", p->slave);
|
||||
return sysfs_emit(buf, "%d\n", p->slave);
|
||||
}
|
||||
|
||||
static struct attribute **
|
||||
@@ -542,14 +540,10 @@ static ssize_t sysfs_show_smi_enabled(struct device *dev,
|
||||
{
|
||||
struct mlx4_port *p =
|
||||
container_of(attr, struct mlx4_port, smi_enabled);
|
||||
ssize_t len = 0;
|
||||
|
||||
if (mlx4_vf_smi_enabled(p->dev->dev, p->slave, p->port_num))
|
||||
len = sprintf(buf, "%d\n", 1);
|
||||
else
|
||||
len = sprintf(buf, "%d\n", 0);
|
||||
|
||||
return len;
|
||||
return sysfs_emit(buf, "%d\n",
|
||||
!!mlx4_vf_smi_enabled(p->dev->dev, p->slave,
|
||||
p->port_num));
|
||||
}
|
||||
|
||||
static ssize_t sysfs_show_enable_smi_admin(struct device *dev,
|
||||
@@ -558,14 +552,10 @@ static ssize_t sysfs_show_enable_smi_admin(struct device *dev,
|
||||
{
|
||||
struct mlx4_port *p =
|
||||
container_of(attr, struct mlx4_port, enable_smi_admin);
|
||||
ssize_t len = 0;
|
||||
|
||||
if (mlx4_vf_get_enable_smi_admin(p->dev->dev, p->slave, p->port_num))
|
||||
len = sprintf(buf, "%d\n", 1);
|
||||
else
|
||||
len = sprintf(buf, "%d\n", 0);
|
||||
|
||||
return len;
|
||||
return sysfs_emit(buf, "%d\n",
|
||||
!!mlx4_vf_get_enable_smi_admin(p->dev->dev, p->slave,
|
||||
p->port_num));
|
||||
}
|
||||
|
||||
static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
|
||||
|
||||
@@ -707,10 +707,10 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
int *cqe_size, int *index, int *inlen)
|
||||
{
|
||||
struct mlx5_ib_create_cq ucmd = {};
|
||||
unsigned long page_size;
|
||||
unsigned int page_offset_quantized;
|
||||
size_t ucmdlen;
|
||||
int page_shift;
|
||||
__be64 *pas;
|
||||
int npages;
|
||||
int ncont;
|
||||
void *cqc;
|
||||
int err;
|
||||
@@ -742,14 +742,24 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
return err;
|
||||
}
|
||||
|
||||
page_size = mlx5_umem_find_best_cq_quantized_pgoff(
|
||||
cq->buf.umem, cqc, log_page_size, MLX5_ADAPTER_PAGE_SHIFT,
|
||||
page_offset, 64, &page_offset_quantized);
|
||||
if (!page_size) {
|
||||
err = -EINVAL;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
err = mlx5_ib_db_map_user(context, udata, ucmd.db_addr, &cq->db);
|
||||
if (err)
|
||||
goto err_umem;
|
||||
|
||||
mlx5_ib_cont_pages(cq->buf.umem, ucmd.buf_addr, 0, &npages, &page_shift,
|
||||
&ncont, NULL);
|
||||
mlx5_ib_dbg(dev, "addr 0x%llx, size %u, npages %d, page_shift %d, ncont %d\n",
|
||||
ucmd.buf_addr, entries * ucmd.cqe_size, npages, page_shift, ncont);
|
||||
ncont = ib_umem_num_dma_blocks(cq->buf.umem, page_size);
|
||||
mlx5_ib_dbg(
|
||||
dev,
|
||||
"addr 0x%llx, size %u, npages %zu, page_size %lu, ncont %d\n",
|
||||
ucmd.buf_addr, entries * ucmd.cqe_size,
|
||||
ib_umem_num_pages(cq->buf.umem), page_size, ncont);
|
||||
|
||||
*inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
|
||||
MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * ncont;
|
||||
@@ -760,11 +770,12 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
}
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
|
||||
mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, pas, 0);
|
||||
mlx5_ib_populate_pas(cq->buf.umem, page_size, pas, 0);
|
||||
|
||||
cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
|
||||
MLX5_SET(cqc, cqc, log_page_size,
|
||||
page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(cqc, cqc, page_offset, page_offset_quantized);
|
||||
|
||||
if (ucmd.flags & MLX5_IB_CREATE_CQ_FLAGS_UAR_PAGE_INDEX) {
|
||||
*index = ucmd.uar_page_index;
|
||||
@@ -1128,13 +1139,12 @@ int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
|
||||
}
|
||||
|
||||
static int resize_user(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
|
||||
int entries, struct ib_udata *udata, int *npas,
|
||||
int *page_shift, int *cqe_size)
|
||||
int entries, struct ib_udata *udata,
|
||||
int *cqe_size)
|
||||
{
|
||||
struct mlx5_ib_resize_cq ucmd;
|
||||
struct ib_umem *umem;
|
||||
int err;
|
||||
int npages;
|
||||
|
||||
err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
|
||||
if (err)
|
||||
@@ -1155,9 +1165,6 @@ static int resize_user(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
|
||||
return err;
|
||||
}
|
||||
|
||||
mlx5_ib_cont_pages(umem, ucmd.buf_addr, 0, &npages, page_shift,
|
||||
npas, NULL);
|
||||
|
||||
cq->resize_umem = umem;
|
||||
*cqe_size = ucmd.cqe_size;
|
||||
|
||||
@@ -1250,7 +1257,8 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
|
||||
int err;
|
||||
int npas;
|
||||
__be64 *pas;
|
||||
int page_shift;
|
||||
unsigned int page_offset_quantized = 0;
|
||||
unsigned int page_shift;
|
||||
int inlen;
|
||||
int cqe_size;
|
||||
unsigned long flags;
|
||||
@@ -1277,22 +1285,34 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
|
||||
|
||||
mutex_lock(&cq->resize_mutex);
|
||||
if (udata) {
|
||||
err = resize_user(dev, cq, entries, udata, &npas, &page_shift,
|
||||
&cqe_size);
|
||||
unsigned long page_size;
|
||||
|
||||
err = resize_user(dev, cq, entries, udata, &cqe_size);
|
||||
if (err)
|
||||
goto ex;
|
||||
|
||||
page_size = mlx5_umem_find_best_cq_quantized_pgoff(
|
||||
cq->resize_umem, cqc, log_page_size,
|
||||
MLX5_ADAPTER_PAGE_SHIFT, page_offset, 64,
|
||||
&page_offset_quantized);
|
||||
if (!page_size) {
|
||||
err = -EINVAL;
|
||||
goto ex_resize;
|
||||
}
|
||||
npas = ib_umem_num_dma_blocks(cq->resize_umem, page_size);
|
||||
page_shift = order_base_2(page_size);
|
||||
} else {
|
||||
struct mlx5_frag_buf *frag_buf;
|
||||
|
||||
cqe_size = 64;
|
||||
err = resize_kernel(dev, cq, entries, cqe_size);
|
||||
if (!err) {
|
||||
struct mlx5_frag_buf *frag_buf = &cq->resize_buf->frag_buf;
|
||||
|
||||
npas = frag_buf->npages;
|
||||
page_shift = frag_buf->page_shift;
|
||||
}
|
||||
if (err)
|
||||
goto ex;
|
||||
frag_buf = &cq->resize_buf->frag_buf;
|
||||
npas = frag_buf->npages;
|
||||
page_shift = frag_buf->page_shift;
|
||||
}
|
||||
|
||||
if (err)
|
||||
goto ex;
|
||||
|
||||
inlen = MLX5_ST_SZ_BYTES(modify_cq_in) +
|
||||
MLX5_FLD_SZ_BYTES(modify_cq_in, pas[0]) * npas;
|
||||
|
||||
@@ -1304,8 +1324,8 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(modify_cq_in, in, pas);
|
||||
if (udata)
|
||||
mlx5_ib_populate_pas(dev, cq->resize_umem, page_shift,
|
||||
pas, 0);
|
||||
mlx5_ib_populate_pas(cq->resize_umem, 1UL << page_shift, pas,
|
||||
0);
|
||||
else
|
||||
mlx5_fill_page_frag_array(&cq->resize_buf->frag_buf, pas);
|
||||
|
||||
@@ -1319,6 +1339,7 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
|
||||
|
||||
MLX5_SET(cqc, cqc, log_page_size,
|
||||
page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(cqc, cqc, page_offset, page_offset_quantized);
|
||||
MLX5_SET(cqc, cqc, cqe_sz,
|
||||
cqe_sz_to_mlx_sz(cqe_size,
|
||||
cq->private_flags &
|
||||
|
||||
@@ -93,9 +93,6 @@ struct devx_async_event_file {
|
||||
struct devx_umem {
|
||||
struct mlx5_core_dev *mdev;
|
||||
struct ib_umem *umem;
|
||||
u32 page_offset;
|
||||
int page_shift;
|
||||
int ncont;
|
||||
u32 dinlen;
|
||||
u32 dinbox[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)];
|
||||
};
|
||||
@@ -1311,7 +1308,7 @@ static int devx_obj_cleanup(struct ib_uobject *uobject,
|
||||
else
|
||||
ret = mlx5_cmd_exec(obj->ib_dev->mdev, obj->dinbox,
|
||||
obj->dinlen, out, sizeof(out));
|
||||
if (ib_is_destroy_retryable(ret, why, uobject))
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
devx_event_table = &dev->devx_event_table;
|
||||
@@ -2057,9 +2054,7 @@ static int devx_umem_get(struct mlx5_ib_dev *dev, struct ib_ucontext *ucontext,
|
||||
u64 addr;
|
||||
size_t size;
|
||||
u32 access;
|
||||
int npages;
|
||||
int err;
|
||||
u32 page_mask;
|
||||
|
||||
if (uverbs_copy_from(&addr, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_ADDR) ||
|
||||
uverbs_copy_from(&size, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_LEN))
|
||||
@@ -2073,57 +2068,62 @@ static int devx_umem_get(struct mlx5_ib_dev *dev, struct ib_ucontext *ucontext,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = ib_check_mr_access(access);
|
||||
err = ib_check_mr_access(&dev->ib_dev, access);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
obj->umem = ib_umem_get(&dev->ib_dev, addr, size, access);
|
||||
if (IS_ERR(obj->umem))
|
||||
return PTR_ERR(obj->umem);
|
||||
|
||||
mlx5_ib_cont_pages(obj->umem, obj->umem->address,
|
||||
MLX5_MKEY_PAGE_SHIFT_MASK, &npages,
|
||||
&obj->page_shift, &obj->ncont, NULL);
|
||||
|
||||
if (!npages) {
|
||||
ib_umem_release(obj->umem);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
page_mask = (1 << obj->page_shift) - 1;
|
||||
obj->page_offset = obj->umem->address & page_mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int devx_umem_reg_cmd_alloc(struct uverbs_attr_bundle *attrs,
|
||||
static int devx_umem_reg_cmd_alloc(struct mlx5_ib_dev *dev,
|
||||
struct uverbs_attr_bundle *attrs,
|
||||
struct devx_umem *obj,
|
||||
struct devx_umem_reg_cmd *cmd)
|
||||
{
|
||||
cmd->inlen = MLX5_ST_SZ_BYTES(create_umem_in) +
|
||||
(MLX5_ST_SZ_BYTES(mtt) * obj->ncont);
|
||||
cmd->in = uverbs_zalloc(attrs, cmd->inlen);
|
||||
return PTR_ERR_OR_ZERO(cmd->in);
|
||||
}
|
||||
|
||||
static void devx_umem_reg_cmd_build(struct mlx5_ib_dev *dev,
|
||||
struct devx_umem *obj,
|
||||
struct devx_umem_reg_cmd *cmd)
|
||||
{
|
||||
void *umem;
|
||||
unsigned int page_size;
|
||||
__be64 *mtt;
|
||||
void *umem;
|
||||
|
||||
/*
|
||||
* We don't know what the user intends to use this umem for, but the HW
|
||||
* restrictions must be met. MR, doorbell records, QP, WQ and CQ all
|
||||
* have different requirements. Since we have no idea how to sort this
|
||||
* out, only support PAGE_SIZE with the expectation that userspace will
|
||||
* provide the necessary alignments inside the known PAGE_SIZE and that
|
||||
* FW will check everything.
|
||||
*/
|
||||
page_size = ib_umem_find_best_pgoff(
|
||||
obj->umem, PAGE_SIZE,
|
||||
__mlx5_page_offset_to_bitmask(__mlx5_bit_sz(umem, page_offset),
|
||||
0));
|
||||
if (!page_size)
|
||||
return -EINVAL;
|
||||
|
||||
cmd->inlen = MLX5_ST_SZ_BYTES(create_umem_in) +
|
||||
(MLX5_ST_SZ_BYTES(mtt) *
|
||||
ib_umem_num_dma_blocks(obj->umem, page_size));
|
||||
cmd->in = uverbs_zalloc(attrs, cmd->inlen);
|
||||
if (IS_ERR(cmd->in))
|
||||
return PTR_ERR(cmd->in);
|
||||
|
||||
umem = MLX5_ADDR_OF(create_umem_in, cmd->in, umem);
|
||||
mtt = (__be64 *)MLX5_ADDR_OF(umem, umem, mtt);
|
||||
|
||||
MLX5_SET(create_umem_in, cmd->in, opcode, MLX5_CMD_OP_CREATE_UMEM);
|
||||
MLX5_SET64(umem, umem, num_of_mtt, obj->ncont);
|
||||
MLX5_SET(umem, umem, log_page_size, obj->page_shift -
|
||||
MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(umem, umem, page_offset, obj->page_offset);
|
||||
mlx5_ib_populate_pas(dev, obj->umem, obj->page_shift, mtt,
|
||||
MLX5_SET64(umem, umem, num_of_mtt,
|
||||
ib_umem_num_dma_blocks(obj->umem, page_size));
|
||||
MLX5_SET(umem, umem, log_page_size,
|
||||
order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(umem, umem, page_offset,
|
||||
ib_umem_dma_offset(obj->umem, page_size));
|
||||
|
||||
mlx5_ib_populate_pas(obj->umem, page_size, mtt,
|
||||
(obj->umem->writable ? MLX5_IB_MTT_WRITE : 0) |
|
||||
MLX5_IB_MTT_READ);
|
||||
MLX5_IB_MTT_READ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)(
|
||||
@@ -2150,12 +2150,10 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)(
|
||||
if (err)
|
||||
goto err_obj_free;
|
||||
|
||||
err = devx_umem_reg_cmd_alloc(attrs, obj, &cmd);
|
||||
err = devx_umem_reg_cmd_alloc(dev, attrs, obj, &cmd);
|
||||
if (err)
|
||||
goto err_umem_release;
|
||||
|
||||
devx_umem_reg_cmd_build(dev, obj, &cmd);
|
||||
|
||||
MLX5_SET(create_umem_in, cmd.in, uid, c->devx_uid);
|
||||
err = mlx5_cmd_exec(dev->mdev, cmd.in, cmd.inlen, cmd.out,
|
||||
sizeof(cmd.out));
|
||||
@@ -2187,7 +2185,7 @@ static int devx_umem_cleanup(struct ib_uobject *uobject,
|
||||
int err;
|
||||
|
||||
err = mlx5_cmd_exec(obj->mdev, obj->dinbox, obj->dinlen, out, sizeof(out));
|
||||
if (ib_is_destroy_retryable(err, why, uobject))
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ib_umem_release(obj->umem);
|
||||
@@ -2600,8 +2598,8 @@ static const struct file_operations devx_async_event_fops = {
|
||||
.llseek = no_llseek,
|
||||
};
|
||||
|
||||
static int devx_async_cmd_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
static void devx_async_cmd_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
{
|
||||
struct devx_async_cmd_event_file *comp_ev_file =
|
||||
container_of(uobj, struct devx_async_cmd_event_file,
|
||||
@@ -2623,11 +2621,10 @@ static int devx_async_cmd_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
kvfree(entry);
|
||||
}
|
||||
spin_unlock_irq(&comp_ev_file->ev_queue.lock);
|
||||
return 0;
|
||||
};
|
||||
|
||||
static int devx_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
static void devx_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
enum rdma_remove_reason why)
|
||||
{
|
||||
struct devx_async_event_file *ev_file =
|
||||
container_of(uobj, struct devx_async_event_file,
|
||||
@@ -2671,7 +2668,6 @@ static int devx_async_event_destroy_uobj(struct ib_uobject *uobj,
|
||||
mutex_unlock(&dev->devx_event_table.event_xa_lock);
|
||||
|
||||
put_device(&dev->ib_dev.dev);
|
||||
return 0;
|
||||
};
|
||||
|
||||
DECLARE_UVERBS_NAMED_METHOD(
|
||||
|
||||
@@ -2035,11 +2035,9 @@ static int flow_matcher_cleanup(struct ib_uobject *uobject,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct mlx5_ib_flow_matcher *obj = uobject->object;
|
||||
int ret;
|
||||
|
||||
ret = ib_destroy_usecnt(&obj->usecnt, why, uobject);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (atomic_read(&obj->usecnt))
|
||||
return -EBUSY;
|
||||
|
||||
kfree(obj);
|
||||
return 0;
|
||||
|
||||
@@ -75,12 +75,6 @@ static LIST_HEAD(mlx5_ib_dev_list);
|
||||
*/
|
||||
static DEFINE_MUTEX(mlx5_ib_multiport_mutex);
|
||||
|
||||
/* We can't use an array for xlt_emergency_page because dma_map_single
|
||||
* doesn't work on kernel modules memory
|
||||
*/
|
||||
static unsigned long xlt_emergency_page;
|
||||
static struct mutex xlt_emergency_page_mutex;
|
||||
|
||||
struct mlx5_ib_dev *mlx5_ib_get_ibdev_from_mpi(struct mlx5_ib_multiport_info *mpi)
|
||||
{
|
||||
struct mlx5_ib_dev *dev;
|
||||
@@ -425,10 +419,22 @@ static int translate_eth_ext_proto_oper(u32 eth_proto_oper, u16 *active_speed,
|
||||
*active_width = IB_WIDTH_2X;
|
||||
*active_speed = IB_SPEED_HDR;
|
||||
break;
|
||||
case MLX5E_PROT_MASK(MLX5E_100GAUI_1_100GBASE_CR_KR):
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_NDR;
|
||||
break;
|
||||
case MLX5E_PROT_MASK(MLX5E_200GAUI_4_200GBASE_CR4_KR4):
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_HDR;
|
||||
break;
|
||||
case MLX5E_PROT_MASK(MLX5E_200GAUI_2_200GBASE_CR2_KR2):
|
||||
*active_width = IB_WIDTH_2X;
|
||||
*active_speed = IB_SPEED_NDR;
|
||||
break;
|
||||
case MLX5E_PROT_MASK(MLX5E_400GAUI_4_400GBASE_CR4_KR4):
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_NDR;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2628,7 +2634,7 @@ static ssize_t fw_pages_show(struct device *device,
|
||||
struct mlx5_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", dev->mdev->priv.fw_pages);
|
||||
return sysfs_emit(buf, "%d\n", dev->mdev->priv.fw_pages);
|
||||
}
|
||||
static DEVICE_ATTR_RO(fw_pages);
|
||||
|
||||
@@ -2638,7 +2644,7 @@ static ssize_t reg_pages_show(struct device *device,
|
||||
struct mlx5_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", atomic_read(&dev->mdev->priv.reg_pages));
|
||||
return sysfs_emit(buf, "%d\n", atomic_read(&dev->mdev->priv.reg_pages));
|
||||
}
|
||||
static DEVICE_ATTR_RO(reg_pages);
|
||||
|
||||
@@ -2648,7 +2654,7 @@ static ssize_t hca_type_show(struct device *device,
|
||||
struct mlx5_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "MT%d\n", dev->mdev->pdev->device);
|
||||
return sysfs_emit(buf, "MT%d\n", dev->mdev->pdev->device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -2658,7 +2664,7 @@ static ssize_t hw_rev_show(struct device *device,
|
||||
struct mlx5_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%x\n", dev->mdev->rev_id);
|
||||
return sysfs_emit(buf, "%x\n", dev->mdev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -2668,8 +2674,8 @@ static ssize_t board_id_show(struct device *device,
|
||||
struct mlx5_ib_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MLX5_BOARD_ID_LEN,
|
||||
dev->mdev->board_id);
|
||||
return sysfs_emit(buf, "%.*s\n", MLX5_BOARD_ID_LEN,
|
||||
dev->mdev->board_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -4024,6 +4030,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = {
|
||||
.create_cq = mlx5_ib_create_cq,
|
||||
.create_qp = mlx5_ib_create_qp,
|
||||
.create_srq = mlx5_ib_create_srq,
|
||||
.create_user_ah = mlx5_ib_create_ah,
|
||||
.dealloc_pd = mlx5_ib_dealloc_pd,
|
||||
.dealloc_ucontext = mlx5_ib_dealloc_ucontext,
|
||||
.del_gid = mlx5_ib_del_gid,
|
||||
@@ -4141,42 +4148,6 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
|
||||
struct mlx5_core_dev *mdev = dev->mdev;
|
||||
int err;
|
||||
|
||||
dev->ib_dev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_AH) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_REREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
|
||||
(1ull << IB_USER_VERBS_CMD_DETACH_MCAST) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_OPEN_QP);
|
||||
dev->ib_dev.uverbs_ex_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_CQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW);
|
||||
|
||||
if (MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads) &&
|
||||
IS_ENABLED(CONFIG_MLX5_CORE_IPOIB))
|
||||
ib_set_device_ops(&dev->ib_dev,
|
||||
@@ -4187,19 +4158,11 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
|
||||
|
||||
dev->umr_fence = mlx5_get_umr_fence(MLX5_CAP_GEN(mdev, umr_fence));
|
||||
|
||||
if (MLX5_CAP_GEN(mdev, imaicl)) {
|
||||
dev->ib_dev.uverbs_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_MW) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_MW);
|
||||
if (MLX5_CAP_GEN(mdev, imaicl))
|
||||
ib_set_device_ops(&dev->ib_dev, &mlx5_ib_dev_mw_ops);
|
||||
}
|
||||
|
||||
if (MLX5_CAP_GEN(mdev, xrc)) {
|
||||
dev->ib_dev.uverbs_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_CMD_OPEN_XRCD) |
|
||||
(1ull << IB_USER_VERBS_CMD_CLOSE_XRCD);
|
||||
if (MLX5_CAP_GEN(mdev, xrc))
|
||||
ib_set_device_ops(&dev->ib_dev, &mlx5_ib_dev_xrc_ops);
|
||||
}
|
||||
|
||||
if (MLX5_CAP_DEV_MEM(mdev, memic) ||
|
||||
MLX5_CAP_GEN_64(dev->mdev, general_obj_types) &
|
||||
@@ -4278,12 +4241,6 @@ static int mlx5_ib_roce_init(struct mlx5_ib_dev *dev)
|
||||
ll = mlx5_port_type_cap_to_rdma_ll(port_type_cap);
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET) {
|
||||
dev->ib_dev.uverbs_ex_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
|
||||
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL);
|
||||
ib_set_device_ops(&dev->ib_dev, &mlx5_ib_dev_common_roce_ops);
|
||||
|
||||
port_num = mlx5_core_native_port_num(dev->mdev) - 1;
|
||||
@@ -4878,30 +4835,17 @@ static struct auxiliary_driver mlx5r_driver = {
|
||||
.id_table = mlx5r_id_table,
|
||||
};
|
||||
|
||||
unsigned long mlx5_ib_get_xlt_emergency_page(void)
|
||||
{
|
||||
mutex_lock(&xlt_emergency_page_mutex);
|
||||
return xlt_emergency_page;
|
||||
}
|
||||
|
||||
void mlx5_ib_put_xlt_emergency_page(void)
|
||||
{
|
||||
mutex_unlock(&xlt_emergency_page_mutex);
|
||||
}
|
||||
|
||||
static int __init mlx5_ib_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
xlt_emergency_page = __get_free_page(GFP_KERNEL);
|
||||
xlt_emergency_page = (void *)__get_free_page(GFP_KERNEL);
|
||||
if (!xlt_emergency_page)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&xlt_emergency_page_mutex);
|
||||
|
||||
mlx5_ib_event_wq = alloc_ordered_workqueue("mlx5_ib_event_wq", 0);
|
||||
if (!mlx5_ib_event_wq) {
|
||||
free_page(xlt_emergency_page);
|
||||
free_page((unsigned long)xlt_emergency_page);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -4934,8 +4878,7 @@ static void __exit mlx5_ib_cleanup(void)
|
||||
mlx5r_rep_cleanup();
|
||||
|
||||
destroy_workqueue(mlx5_ib_event_wq);
|
||||
mutex_destroy(&xlt_emergency_page_mutex);
|
||||
free_page(xlt_emergency_page);
|
||||
free_page((unsigned long)xlt_emergency_page);
|
||||
}
|
||||
|
||||
module_init(mlx5_ib_init);
|
||||
|
||||
@@ -36,161 +36,65 @@
|
||||
#include "mlx5_ib.h"
|
||||
#include <linux/jiffies.h>
|
||||
|
||||
/* @umem: umem object to scan
|
||||
* @addr: ib virtual address requested by the user
|
||||
* @max_page_shift: high limit for page_shift - 0 means no limit
|
||||
* @count: number of PAGE_SIZE pages covered by umem
|
||||
* @shift: page shift for the compound pages found in the region
|
||||
* @ncont: number of compund pages
|
||||
* @order: log2 of the number of compound pages
|
||||
/*
|
||||
* Fill in a physical address list. ib_umem_num_dma_blocks() entries will be
|
||||
* filled in the pas array.
|
||||
*/
|
||||
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
|
||||
unsigned long max_page_shift,
|
||||
int *count, int *shift,
|
||||
int *ncont, int *order)
|
||||
void mlx5_ib_populate_pas(struct ib_umem *umem, size_t page_size, __be64 *pas,
|
||||
u64 access_flags)
|
||||
{
|
||||
unsigned long tmp;
|
||||
unsigned long m;
|
||||
u64 base = ~0, p = 0;
|
||||
u64 len, pfn;
|
||||
int i = 0;
|
||||
struct scatterlist *sg;
|
||||
int entry;
|
||||
struct ib_block_iter biter;
|
||||
|
||||
addr = addr >> PAGE_SHIFT;
|
||||
tmp = (unsigned long)addr;
|
||||
m = find_first_bit(&tmp, BITS_PER_LONG);
|
||||
if (max_page_shift)
|
||||
m = min_t(unsigned long, max_page_shift - PAGE_SHIFT, m);
|
||||
|
||||
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
|
||||
len = sg_dma_len(sg) >> PAGE_SHIFT;
|
||||
pfn = sg_dma_address(sg) >> PAGE_SHIFT;
|
||||
if (base + p != pfn) {
|
||||
/* If either the offset or the new
|
||||
* base are unaligned update m
|
||||
*/
|
||||
tmp = (unsigned long)(pfn | p);
|
||||
if (!IS_ALIGNED(tmp, 1 << m))
|
||||
m = find_first_bit(&tmp, BITS_PER_LONG);
|
||||
|
||||
base = pfn;
|
||||
p = 0;
|
||||
}
|
||||
|
||||
p += len;
|
||||
i += len;
|
||||
rdma_umem_for_each_dma_block (umem, &biter, page_size) {
|
||||
*pas = cpu_to_be64(rdma_block_iter_dma_address(&biter) |
|
||||
access_flags);
|
||||
pas++;
|
||||
}
|
||||
|
||||
if (i) {
|
||||
m = min_t(unsigned long, ilog2(roundup_pow_of_two(i)), m);
|
||||
|
||||
if (order)
|
||||
*order = ilog2(roundup_pow_of_two(i) >> m);
|
||||
|
||||
*ncont = DIV_ROUND_UP(i, (1 << m));
|
||||
} else {
|
||||
m = 0;
|
||||
|
||||
if (order)
|
||||
*order = 0;
|
||||
|
||||
*ncont = 0;
|
||||
}
|
||||
*shift = PAGE_SHIFT + m;
|
||||
*count = i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Populate the given array with bus addresses from the umem.
|
||||
*
|
||||
* dev - mlx5_ib device
|
||||
* umem - umem to use to fill the pages
|
||||
* page_shift - determines the page size used in the resulting array
|
||||
* offset - offset into the umem to start from,
|
||||
* only implemented for ODP umems
|
||||
* num_pages - total number of pages to fill
|
||||
* pas - bus addresses array to fill
|
||||
* access_flags - access flags to set on all present pages.
|
||||
use enum mlx5_ib_mtt_access_flags for this.
|
||||
* Compute the page shift and page_offset for mailboxes that use a quantized
|
||||
* page_offset. The granulatity of the page offset scales according to page
|
||||
* size.
|
||||
*/
|
||||
void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, size_t offset, size_t num_pages,
|
||||
__be64 *pas, int access_flags)
|
||||
unsigned long __mlx5_umem_find_best_quantized_pgoff(
|
||||
struct ib_umem *umem, unsigned long pgsz_bitmap,
|
||||
unsigned int page_offset_bits, u64 pgoff_bitmask, unsigned int scale,
|
||||
unsigned int *page_offset_quantized)
|
||||
{
|
||||
int shift = page_shift - PAGE_SHIFT;
|
||||
int mask = (1 << shift) - 1;
|
||||
int i, k, idx;
|
||||
u64 cur = 0;
|
||||
u64 base;
|
||||
int len;
|
||||
struct scatterlist *sg;
|
||||
int entry;
|
||||
const u64 page_offset_mask = (1UL << page_offset_bits) - 1;
|
||||
unsigned long page_size;
|
||||
u64 page_offset;
|
||||
|
||||
i = 0;
|
||||
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
|
||||
len = sg_dma_len(sg) >> PAGE_SHIFT;
|
||||
base = sg_dma_address(sg);
|
||||
page_size = ib_umem_find_best_pgoff(umem, pgsz_bitmap, pgoff_bitmask);
|
||||
if (!page_size)
|
||||
return 0;
|
||||
|
||||
/* Skip elements below offset */
|
||||
if (i + len < offset << shift) {
|
||||
i += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip pages below offset */
|
||||
if (i < offset << shift) {
|
||||
k = (offset << shift) - i;
|
||||
i = offset << shift;
|
||||
} else {
|
||||
k = 0;
|
||||
}
|
||||
|
||||
for (; k < len; k++) {
|
||||
if (!(i & mask)) {
|
||||
cur = base + (k << PAGE_SHIFT);
|
||||
cur |= access_flags;
|
||||
idx = (i >> shift) - offset;
|
||||
|
||||
pas[idx] = cpu_to_be64(cur);
|
||||
mlx5_ib_dbg(dev, "pas[%d] 0x%llx\n",
|
||||
i >> shift, be64_to_cpu(pas[idx]));
|
||||
}
|
||||
i++;
|
||||
|
||||
/* Stop after num_pages reached */
|
||||
if (i >> shift >= offset + num_pages)
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* page size is the largest possible page size.
|
||||
*
|
||||
* Reduce the page_size, and thus the page_offset and quanta, until the
|
||||
* page_offset fits into the mailbox field. Once page_size < scale this
|
||||
* loop is guaranteed to terminate.
|
||||
*/
|
||||
page_offset = ib_umem_dma_offset(umem, page_size);
|
||||
while (page_offset & ~(u64)(page_offset_mask * (page_size / scale))) {
|
||||
page_size /= 2;
|
||||
page_offset = ib_umem_dma_offset(umem, page_size);
|
||||
}
|
||||
}
|
||||
|
||||
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, __be64 *pas, int access_flags)
|
||||
{
|
||||
return __mlx5_ib_populate_pas(dev, umem, page_shift, 0,
|
||||
ib_umem_num_dma_blocks(umem, PAGE_SIZE),
|
||||
pas, access_flags);
|
||||
}
|
||||
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset)
|
||||
{
|
||||
u64 page_size;
|
||||
u64 page_mask;
|
||||
u64 off_size;
|
||||
u64 off_mask;
|
||||
u64 buf_off;
|
||||
/*
|
||||
* The address is not aligned, or otherwise cannot be represented by the
|
||||
* page_offset.
|
||||
*/
|
||||
if (!(pgsz_bitmap & page_size))
|
||||
return 0;
|
||||
|
||||
page_size = (u64)1 << page_shift;
|
||||
page_mask = page_size - 1;
|
||||
buf_off = addr & page_mask;
|
||||
off_size = page_size >> 6;
|
||||
off_mask = off_size - 1;
|
||||
|
||||
if (buf_off & off_mask)
|
||||
return -EINVAL;
|
||||
|
||||
*offset = buf_off >> ilog2(off_size);
|
||||
return 0;
|
||||
*page_offset_quantized =
|
||||
(unsigned long)page_offset / (page_size / scale);
|
||||
if (WARN_ON(*page_offset_quantized > page_offset_mask))
|
||||
return 0;
|
||||
return page_size;
|
||||
}
|
||||
|
||||
#define WR_ID_BF 0xBF
|
||||
|
||||
@@ -40,7 +40,73 @@
|
||||
#define MLX5_IB_DEFAULT_UIDX 0xffffff
|
||||
#define MLX5_USER_ASSIGNED_UIDX_MASK __mlx5_mask(qpc, user_index)
|
||||
|
||||
#define MLX5_MKEY_PAGE_SHIFT_MASK __mlx5_mask(mkc, log_page_size)
|
||||
static __always_inline unsigned long
|
||||
__mlx5_log_page_size_to_bitmap(unsigned int log_pgsz_bits,
|
||||
unsigned int pgsz_shift)
|
||||
{
|
||||
unsigned int largest_pg_shift =
|
||||
min_t(unsigned long, (1ULL << log_pgsz_bits) - 1 + pgsz_shift,
|
||||
BITS_PER_LONG - 1);
|
||||
|
||||
/*
|
||||
* Despite a command allowing it, the device does not support lower than
|
||||
* 4k page size.
|
||||
*/
|
||||
pgsz_shift = max_t(unsigned int, MLX5_ADAPTER_PAGE_SHIFT, pgsz_shift);
|
||||
return GENMASK(largest_pg_shift, pgsz_shift);
|
||||
}
|
||||
|
||||
/*
|
||||
* For mkc users, instead of a page_offset the command has a start_iova which
|
||||
* specifies both the page_offset and the on-the-wire IOVA
|
||||
*/
|
||||
#define mlx5_umem_find_best_pgsz(umem, typ, log_pgsz_fld, pgsz_shift, iova) \
|
||||
ib_umem_find_best_pgsz(umem, \
|
||||
__mlx5_log_page_size_to_bitmap( \
|
||||
__mlx5_bit_sz(typ, log_pgsz_fld), \
|
||||
pgsz_shift), \
|
||||
iova)
|
||||
|
||||
static __always_inline unsigned long
|
||||
__mlx5_page_offset_to_bitmask(unsigned int page_offset_bits,
|
||||
unsigned int offset_shift)
|
||||
{
|
||||
unsigned int largest_offset_shift =
|
||||
min_t(unsigned long, page_offset_bits - 1 + offset_shift,
|
||||
BITS_PER_LONG - 1);
|
||||
|
||||
return GENMASK(largest_offset_shift, offset_shift);
|
||||
}
|
||||
|
||||
/*
|
||||
* QP/CQ/WQ/etc type commands take a page offset that satisifies:
|
||||
* page_offset_quantized * (page_size/scale) = page_offset
|
||||
* Which restricts allowed page sizes to ones that satisify the above.
|
||||
*/
|
||||
unsigned long __mlx5_umem_find_best_quantized_pgoff(
|
||||
struct ib_umem *umem, unsigned long pgsz_bitmap,
|
||||
unsigned int page_offset_bits, u64 pgoff_bitmask, unsigned int scale,
|
||||
unsigned int *page_offset_quantized);
|
||||
#define mlx5_umem_find_best_quantized_pgoff(umem, typ, log_pgsz_fld, \
|
||||
pgsz_shift, page_offset_fld, \
|
||||
scale, page_offset_quantized) \
|
||||
__mlx5_umem_find_best_quantized_pgoff( \
|
||||
umem, \
|
||||
__mlx5_log_page_size_to_bitmap( \
|
||||
__mlx5_bit_sz(typ, log_pgsz_fld), pgsz_shift), \
|
||||
__mlx5_bit_sz(typ, page_offset_fld), \
|
||||
GENMASK(31, order_base_2(scale)), scale, \
|
||||
page_offset_quantized)
|
||||
|
||||
#define mlx5_umem_find_best_cq_quantized_pgoff(umem, typ, log_pgsz_fld, \
|
||||
pgsz_shift, page_offset_fld, \
|
||||
scale, page_offset_quantized) \
|
||||
__mlx5_umem_find_best_quantized_pgoff( \
|
||||
umem, \
|
||||
__mlx5_log_page_size_to_bitmap( \
|
||||
__mlx5_bit_sz(typ, log_pgsz_fld), pgsz_shift), \
|
||||
__mlx5_bit_sz(typ, page_offset_fld), 0, scale, \
|
||||
page_offset_quantized)
|
||||
|
||||
enum {
|
||||
MLX5_IB_MMAP_OFFSET_START = 9,
|
||||
@@ -597,14 +663,12 @@ struct mlx5_ib_mr {
|
||||
int max_descs;
|
||||
int desc_size;
|
||||
int access_mode;
|
||||
unsigned int page_shift;
|
||||
struct mlx5_core_mkey mmkey;
|
||||
struct ib_umem *umem;
|
||||
struct mlx5_shared_mr_info *smr_info;
|
||||
struct list_head list;
|
||||
unsigned int order;
|
||||
struct mlx5_cache_ent *cache_ent;
|
||||
int npages;
|
||||
struct mlx5_ib_dev *dev;
|
||||
u32 out[MLX5_ST_SZ_DW(create_mkey_out)];
|
||||
struct mlx5_core_sig_ctx *sig;
|
||||
void *descs_alloc;
|
||||
@@ -1042,6 +1106,11 @@ static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
|
||||
return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_dev *mr_to_mdev(struct mlx5_ib_mr *mr)
|
||||
{
|
||||
return to_mdev(mr->ibmr.device);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_dev *mlx5_udata_to_mdev(struct ib_udata *udata)
|
||||
{
|
||||
struct mlx5_ib_ucontext *context = rdma_udata_to_drv_context(
|
||||
@@ -1189,9 +1258,9 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
|
||||
int access_flags);
|
||||
void mlx5_ib_free_implicit_mr(struct mlx5_ib_mr *mr);
|
||||
void mlx5_ib_fence_odp_mr(struct mlx5_ib_mr *mr);
|
||||
int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr, int access_flags,
|
||||
struct ib_pd *pd, struct ib_udata *udata);
|
||||
struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr, int access_flags,
|
||||
struct ib_pd *pd, struct ib_udata *udata);
|
||||
int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
|
||||
struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
u32 max_num_sg);
|
||||
@@ -1210,7 +1279,6 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
|
||||
size_t *out_mad_size, u16 *out_mad_pkey_index);
|
||||
int mlx5_ib_alloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata);
|
||||
int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata);
|
||||
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset);
|
||||
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
|
||||
int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
|
||||
struct ib_smp *out_mad);
|
||||
@@ -1230,15 +1298,8 @@ int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
|
||||
unsigned long max_page_shift,
|
||||
int *count, int *shift,
|
||||
int *ncont, int *order);
|
||||
void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, size_t offset, size_t num_pages,
|
||||
__be64 *pas, int access_flags);
|
||||
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, __be64 *pas, int access_flags);
|
||||
void mlx5_ib_populate_pas(struct ib_umem *umem, size_t page_size, __be64 *pas,
|
||||
u64 access_flags);
|
||||
void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num);
|
||||
int mlx5_ib_get_cqe_size(struct ib_cq *ibcq);
|
||||
int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
|
||||
@@ -1283,7 +1344,7 @@ void mlx5_odp_populate_xlt(void *xlt, size_t idx, size_t nentries,
|
||||
int mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
|
||||
enum ib_uverbs_advise_mr_advice advice,
|
||||
u32 flags, struct ib_sge *sg_list, u32 num_sge);
|
||||
int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, bool enable);
|
||||
int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr);
|
||||
#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
|
||||
static inline void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
|
||||
{
|
||||
@@ -1305,7 +1366,7 @@ mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, bool enable)
|
||||
static inline int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -1456,8 +1517,7 @@ static inline int get_num_static_uars(struct mlx5_ib_dev *dev,
|
||||
return get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * bfregi->num_static_sys_pages;
|
||||
}
|
||||
|
||||
unsigned long mlx5_ib_get_xlt_emergency_page(void);
|
||||
void mlx5_ib_put_xlt_emergency_page(void);
|
||||
extern void *xlt_emergency_page;
|
||||
|
||||
int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
|
||||
struct mlx5_bfreg_info *bfregi, u32 bfregn,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ static void populate_klm(struct mlx5_klm *pklm, size_t idx, size_t nentries,
|
||||
if (flags & MLX5_IB_UPD_XLT_ZAP) {
|
||||
for (; pklm != end; pklm++, idx++) {
|
||||
pklm->bcount = cpu_to_be32(MLX5_IMR_MTT_SIZE);
|
||||
pklm->key = cpu_to_be32(imr->dev->null_mkey);
|
||||
pklm->key = cpu_to_be32(mr_to_mdev(imr)->null_mkey);
|
||||
pklm->va = 0;
|
||||
}
|
||||
return;
|
||||
@@ -129,7 +129,7 @@ static void populate_klm(struct mlx5_klm *pklm, size_t idx, size_t nentries,
|
||||
* locking around the xarray.
|
||||
*/
|
||||
lockdep_assert_held(&to_ib_umem_odp(imr->umem)->umem_mutex);
|
||||
lockdep_assert_held(&imr->dev->odp_srcu);
|
||||
lockdep_assert_held(&mr_to_mdev(imr)->odp_srcu);
|
||||
|
||||
for (; pklm != end; pklm++, idx++) {
|
||||
struct mlx5_ib_mr *mtt = xa_load(&imr->implicit_children, idx);
|
||||
@@ -139,7 +139,7 @@ static void populate_klm(struct mlx5_klm *pklm, size_t idx, size_t nentries,
|
||||
pklm->key = cpu_to_be32(mtt->ibmr.lkey);
|
||||
pklm->va = cpu_to_be64(idx * MLX5_IMR_MTT_SIZE);
|
||||
} else {
|
||||
pklm->key = cpu_to_be32(imr->dev->null_mkey);
|
||||
pklm->key = cpu_to_be32(mr_to_mdev(imr)->null_mkey);
|
||||
pklm->va = 0;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ static void dma_fence_odp_mr(struct mlx5_ib_mr *mr)
|
||||
mutex_unlock(&odp->umem_mutex);
|
||||
|
||||
if (!mr->cache_ent) {
|
||||
mlx5_core_destroy_mkey(mr->dev->mdev, &mr->mmkey);
|
||||
mlx5_core_destroy_mkey(mr_to_mdev(mr)->mdev, &mr->mmkey);
|
||||
WARN_ON(mr->descs);
|
||||
}
|
||||
}
|
||||
@@ -222,19 +222,19 @@ static void free_implicit_child_mr(struct mlx5_ib_mr *mr, bool need_imr_xlt)
|
||||
WARN_ON(atomic_read(&mr->num_deferred_work));
|
||||
|
||||
if (need_imr_xlt) {
|
||||
srcu_key = srcu_read_lock(&mr->dev->odp_srcu);
|
||||
srcu_key = srcu_read_lock(&mr_to_mdev(mr)->odp_srcu);
|
||||
mutex_lock(&odp_imr->umem_mutex);
|
||||
mlx5_ib_update_xlt(mr->parent, idx, 1, 0,
|
||||
MLX5_IB_UPD_XLT_INDIRECT |
|
||||
MLX5_IB_UPD_XLT_ATOMIC);
|
||||
mutex_unlock(&odp_imr->umem_mutex);
|
||||
srcu_read_unlock(&mr->dev->odp_srcu, srcu_key);
|
||||
srcu_read_unlock(&mr_to_mdev(mr)->odp_srcu, srcu_key);
|
||||
}
|
||||
|
||||
dma_fence_odp_mr(mr);
|
||||
|
||||
mr->parent = NULL;
|
||||
mlx5_mr_cache_free(mr->dev, mr);
|
||||
mlx5_mr_cache_free(mr_to_mdev(mr), mr);
|
||||
ib_umem_odp_release(odp);
|
||||
if (atomic_dec_and_test(&imr->num_deferred_work))
|
||||
wake_up(&imr->q_deferred_work);
|
||||
@@ -274,7 +274,7 @@ static void destroy_unused_implicit_child_mr(struct mlx5_ib_mr *mr)
|
||||
goto out_unlock;
|
||||
|
||||
atomic_inc(&imr->num_deferred_work);
|
||||
call_srcu(&mr->dev->odp_srcu, &mr->odp_destroy.rcu,
|
||||
call_srcu(&mr_to_mdev(mr)->odp_srcu, &mr->odp_destroy.rcu,
|
||||
free_implicit_child_mr_rcu);
|
||||
|
||||
out_unlock:
|
||||
@@ -476,12 +476,13 @@ static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr,
|
||||
if (IS_ERR(odp))
|
||||
return ERR_CAST(odp);
|
||||
|
||||
ret = mr = mlx5_mr_cache_alloc(imr->dev, MLX5_IMR_MTT_CACHE_ENTRY,
|
||||
imr->access_flags);
|
||||
ret = mr = mlx5_mr_cache_alloc(
|
||||
mr_to_mdev(imr), MLX5_IMR_MTT_CACHE_ENTRY, imr->access_flags);
|
||||
if (IS_ERR(mr))
|
||||
goto out_umem;
|
||||
|
||||
mr->ibmr.pd = imr->ibmr.pd;
|
||||
mr->ibmr.device = &mr_to_mdev(imr)->ib_dev;
|
||||
mr->umem = &odp->umem;
|
||||
mr->ibmr.lkey = mr->mmkey.key;
|
||||
mr->ibmr.rkey = mr->mmkey.key;
|
||||
@@ -517,11 +518,11 @@ static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr,
|
||||
goto out_mr;
|
||||
}
|
||||
|
||||
mlx5_ib_dbg(imr->dev, "key %x mr %p\n", mr->mmkey.key, mr);
|
||||
mlx5_ib_dbg(mr_to_mdev(imr), "key %x mr %p\n", mr->mmkey.key, mr);
|
||||
return mr;
|
||||
|
||||
out_mr:
|
||||
mlx5_mr_cache_free(imr->dev, mr);
|
||||
mlx5_mr_cache_free(mr_to_mdev(imr), mr);
|
||||
out_umem:
|
||||
ib_umem_odp_release(odp);
|
||||
return ret;
|
||||
@@ -536,6 +537,10 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
|
||||
struct mlx5_ib_mr *imr;
|
||||
int err;
|
||||
|
||||
if (!mlx5_ib_can_load_pas_with_umr(dev,
|
||||
MLX5_IMR_MTT_ENTRIES * PAGE_SIZE))
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
umem_odp = ib_umem_odp_alloc_implicit(&dev->ib_dev, access_flags);
|
||||
if (IS_ERR(umem_odp))
|
||||
return ERR_CAST(umem_odp);
|
||||
@@ -551,6 +556,7 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
|
||||
imr->umem = &umem_odp->umem;
|
||||
imr->ibmr.lkey = imr->mmkey.key;
|
||||
imr->ibmr.rkey = imr->mmkey.key;
|
||||
imr->ibmr.device = &dev->ib_dev;
|
||||
imr->umem = &umem_odp->umem;
|
||||
imr->is_odp_implicit = true;
|
||||
atomic_set(&imr->num_deferred_work, 0);
|
||||
@@ -584,7 +590,7 @@ out_umem:
|
||||
void mlx5_ib_free_implicit_mr(struct mlx5_ib_mr *imr)
|
||||
{
|
||||
struct ib_umem_odp *odp_imr = to_ib_umem_odp(imr->umem);
|
||||
struct mlx5_ib_dev *dev = imr->dev;
|
||||
struct mlx5_ib_dev *dev = mr_to_mdev(imr);
|
||||
struct list_head destroy_list;
|
||||
struct mlx5_ib_mr *mtt;
|
||||
struct mlx5_ib_mr *tmp;
|
||||
@@ -654,10 +660,10 @@ void mlx5_ib_free_implicit_mr(struct mlx5_ib_mr *imr)
|
||||
void mlx5_ib_fence_odp_mr(struct mlx5_ib_mr *mr)
|
||||
{
|
||||
/* Prevent new page faults and prefetch requests from succeeding */
|
||||
xa_erase(&mr->dev->odp_mkeys, mlx5_base_mkey(mr->mmkey.key));
|
||||
xa_erase(&mr_to_mdev(mr)->odp_mkeys, mlx5_base_mkey(mr->mmkey.key));
|
||||
|
||||
/* Wait for all running page-fault handlers to finish. */
|
||||
synchronize_srcu(&mr->dev->odp_srcu);
|
||||
synchronize_srcu(&mr_to_mdev(mr)->odp_srcu);
|
||||
|
||||
wait_event(mr->q_deferred_work, !atomic_read(&mr->num_deferred_work));
|
||||
|
||||
@@ -701,7 +707,7 @@ static int pagefault_real_mr(struct mlx5_ib_mr *mr, struct ib_umem_odp *odp,
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret != -EAGAIN)
|
||||
mlx5_ib_err(mr->dev,
|
||||
mlx5_ib_err(mr_to_mdev(mr),
|
||||
"Failed to update mkey page tables\n");
|
||||
goto out;
|
||||
}
|
||||
@@ -791,7 +797,7 @@ out:
|
||||
MLX5_IB_UPD_XLT_ATOMIC);
|
||||
mutex_unlock(&odp_imr->umem_mutex);
|
||||
if (err) {
|
||||
mlx5_ib_err(imr->dev, "Failed to update PAS\n");
|
||||
mlx5_ib_err(mr_to_mdev(imr), "Failed to update PAS\n");
|
||||
return err;
|
||||
}
|
||||
return ret;
|
||||
@@ -811,7 +817,7 @@ static int pagefault_mr(struct mlx5_ib_mr *mr, u64 io_virt, size_t bcnt,
|
||||
{
|
||||
struct ib_umem_odp *odp = to_ib_umem_odp(mr->umem);
|
||||
|
||||
lockdep_assert_held(&mr->dev->odp_srcu);
|
||||
lockdep_assert_held(&mr_to_mdev(mr)->odp_srcu);
|
||||
if (unlikely(io_virt < mr->mmkey.iova))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -831,17 +837,13 @@ static int pagefault_mr(struct mlx5_ib_mr *mr, u64 io_virt, size_t bcnt,
|
||||
flags);
|
||||
}
|
||||
|
||||
int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, bool enable)
|
||||
int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr)
|
||||
{
|
||||
u32 flags = MLX5_PF_FLAGS_SNAPSHOT;
|
||||
int ret;
|
||||
|
||||
if (enable)
|
||||
flags |= MLX5_PF_FLAGS_ENABLE;
|
||||
|
||||
ret = pagefault_real_mr(mr, to_ib_umem_odp(mr->umem),
|
||||
mr->umem->address, mr->umem->length, NULL,
|
||||
flags);
|
||||
ret = pagefault_real_mr(mr, to_ib_umem_odp(mr->umem), mr->umem->address,
|
||||
mr->umem->length, NULL,
|
||||
MLX5_PF_FLAGS_SNAPSHOT | MLX5_PF_FLAGS_ENABLE);
|
||||
return ret >= 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
@@ -1783,7 +1785,7 @@ static void mlx5_ib_prefetch_mr_work(struct work_struct *w)
|
||||
|
||||
/* We rely on IB/core that work is executed if we have num_sge != 0 only. */
|
||||
WARN_ON(!work->num_sge);
|
||||
dev = work->frags[0].mr->dev;
|
||||
dev = mr_to_mdev(work->frags[0].mr);
|
||||
/* SRCU should be held when calling to mlx5_odp_populate_xlt() */
|
||||
srcu_key = srcu_read_lock(&dev->odp_srcu);
|
||||
for (i = 0; i < work->num_sge; ++i) {
|
||||
|
||||
@@ -778,39 +778,6 @@ int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
|
||||
return bfregi->sys_pages[index_of_sys_page] + offset;
|
||||
}
|
||||
|
||||
static int mlx5_ib_umem_get(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
unsigned long addr, size_t size,
|
||||
struct ib_umem **umem, int *npages, int *page_shift,
|
||||
int *ncont, u32 *offset)
|
||||
{
|
||||
int err;
|
||||
|
||||
*umem = ib_umem_get(&dev->ib_dev, addr, size, 0);
|
||||
if (IS_ERR(*umem)) {
|
||||
mlx5_ib_dbg(dev, "umem_get failed\n");
|
||||
return PTR_ERR(*umem);
|
||||
}
|
||||
|
||||
mlx5_ib_cont_pages(*umem, addr, 0, npages, page_shift, ncont, NULL);
|
||||
|
||||
err = mlx5_ib_get_buf_offset(addr, *page_shift, offset);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "bad offset\n");
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
mlx5_ib_dbg(dev, "addr 0x%lx, size %zu, npages %d, page_shift %d, ncont %d, offset %d\n",
|
||||
addr, size, *npages, *page_shift, *ncont, *offset);
|
||||
|
||||
return 0;
|
||||
|
||||
err_umem:
|
||||
ib_umem_release(*umem);
|
||||
*umem = NULL;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void destroy_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
struct mlx5_ib_rwq *rwq, struct ib_udata *udata)
|
||||
{
|
||||
@@ -833,10 +800,8 @@ static int create_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
{
|
||||
struct mlx5_ib_ucontext *ucontext = rdma_udata_to_drv_context(
|
||||
udata, struct mlx5_ib_ucontext, ibucontext);
|
||||
int page_shift = 0;
|
||||
int npages;
|
||||
unsigned long page_size = 0;
|
||||
u32 offset = 0;
|
||||
int ncont = 0;
|
||||
int err;
|
||||
|
||||
if (!ucmd->buf_addr)
|
||||
@@ -849,23 +814,26 @@ static int create_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
return err;
|
||||
}
|
||||
|
||||
mlx5_ib_cont_pages(rwq->umem, ucmd->buf_addr, 0, &npages, &page_shift,
|
||||
&ncont, NULL);
|
||||
err = mlx5_ib_get_buf_offset(ucmd->buf_addr, page_shift,
|
||||
&rwq->rq_page_offset);
|
||||
if (err) {
|
||||
page_size = mlx5_umem_find_best_quantized_pgoff(
|
||||
rwq->umem, wq, log_wq_pg_sz, MLX5_ADAPTER_PAGE_SHIFT,
|
||||
page_offset, 64, &rwq->rq_page_offset);
|
||||
if (!page_size) {
|
||||
mlx5_ib_warn(dev, "bad offset\n");
|
||||
err = -EINVAL;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
rwq->rq_num_pas = ncont;
|
||||
rwq->page_shift = page_shift;
|
||||
rwq->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
rwq->rq_num_pas = ib_umem_num_dma_blocks(rwq->umem, page_size);
|
||||
rwq->page_shift = order_base_2(page_size);
|
||||
rwq->log_page_size = rwq->page_shift - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
rwq->wq_sig = !!(ucmd->flags & MLX5_WQ_FLAG_SIGNATURE);
|
||||
|
||||
mlx5_ib_dbg(dev, "addr 0x%llx, size %zd, npages %d, page_shift %d, ncont %d, offset %d\n",
|
||||
(unsigned long long)ucmd->buf_addr, rwq->buf_size,
|
||||
npages, page_shift, ncont, offset);
|
||||
mlx5_ib_dbg(
|
||||
dev,
|
||||
"addr 0x%llx, size %zd, npages %zu, page_size %ld, ncont %d, offset %d\n",
|
||||
(unsigned long long)ucmd->buf_addr, rwq->buf_size,
|
||||
ib_umem_num_pages(rwq->umem), page_size, rwq->rq_num_pas,
|
||||
offset);
|
||||
|
||||
err = mlx5_ib_db_map_user(ucontext, udata, ucmd->db_addr, &rwq->db);
|
||||
if (err) {
|
||||
@@ -896,10 +864,9 @@ static int _create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
{
|
||||
struct mlx5_ib_ucontext *context;
|
||||
struct mlx5_ib_ubuffer *ubuffer = &base->ubuffer;
|
||||
int page_shift = 0;
|
||||
unsigned int page_offset_quantized = 0;
|
||||
unsigned long page_size = 0;
|
||||
int uar_index = 0;
|
||||
int npages;
|
||||
u32 offset = 0;
|
||||
int bfregn;
|
||||
int ncont = 0;
|
||||
__be64 *pas;
|
||||
@@ -950,11 +917,21 @@ static int _create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
|
||||
if (ucmd->buf_addr && ubuffer->buf_size) {
|
||||
ubuffer->buf_addr = ucmd->buf_addr;
|
||||
err = mlx5_ib_umem_get(dev, udata, ubuffer->buf_addr,
|
||||
ubuffer->buf_size, &ubuffer->umem,
|
||||
&npages, &page_shift, &ncont, &offset);
|
||||
if (err)
|
||||
ubuffer->umem = ib_umem_get(&dev->ib_dev, ubuffer->buf_addr,
|
||||
ubuffer->buf_size, 0);
|
||||
if (IS_ERR(ubuffer->umem)) {
|
||||
err = PTR_ERR(ubuffer->umem);
|
||||
goto err_bfreg;
|
||||
}
|
||||
page_size = mlx5_umem_find_best_quantized_pgoff(
|
||||
ubuffer->umem, qpc, log_page_size,
|
||||
MLX5_ADAPTER_PAGE_SHIFT, page_offset, 64,
|
||||
&page_offset_quantized);
|
||||
if (!page_size) {
|
||||
err = -EINVAL;
|
||||
goto err_umem;
|
||||
}
|
||||
ncont = ib_umem_num_dma_blocks(ubuffer->umem, page_size);
|
||||
} else {
|
||||
ubuffer->umem = NULL;
|
||||
}
|
||||
@@ -969,15 +946,14 @@ static int _create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
|
||||
uid = (attr->qp_type != IB_QPT_XRC_INI) ? to_mpd(pd)->uid : 0;
|
||||
MLX5_SET(create_qp_in, *in, uid, uid);
|
||||
pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
|
||||
if (ubuffer->umem)
|
||||
mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
|
||||
|
||||
qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
|
||||
|
||||
MLX5_SET(qpc, qpc, log_page_size, page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(qpc, qpc, page_offset, offset);
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
|
||||
if (ubuffer->umem) {
|
||||
mlx5_ib_populate_pas(ubuffer->umem, page_size, pas, 0);
|
||||
MLX5_SET(qpc, qpc, log_page_size,
|
||||
order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(qpc, qpc, page_offset, page_offset_quantized);
|
||||
}
|
||||
MLX5_SET(qpc, qpc, uar_page, uar_index);
|
||||
if (bfregn != MLX5_IB_INVALID_BFREG)
|
||||
resp->bfreg_index = adjust_bfregn(dev, &context->bfregi, bfregn);
|
||||
@@ -1209,18 +1185,24 @@ static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
|
||||
void *wq;
|
||||
int inlen;
|
||||
int err;
|
||||
int page_shift = 0;
|
||||
int npages;
|
||||
int ncont = 0;
|
||||
u32 offset = 0;
|
||||
unsigned int page_offset_quantized;
|
||||
unsigned long page_size;
|
||||
|
||||
err = mlx5_ib_umem_get(dev, udata, ubuffer->buf_addr, ubuffer->buf_size,
|
||||
&sq->ubuffer.umem, &npages, &page_shift, &ncont,
|
||||
&offset);
|
||||
if (err)
|
||||
return err;
|
||||
sq->ubuffer.umem = ib_umem_get(&dev->ib_dev, ubuffer->buf_addr,
|
||||
ubuffer->buf_size, 0);
|
||||
if (IS_ERR(sq->ubuffer.umem))
|
||||
return PTR_ERR(sq->ubuffer.umem);
|
||||
page_size = mlx5_umem_find_best_quantized_pgoff(
|
||||
ubuffer->umem, wq, log_wq_pg_sz, MLX5_ADAPTER_PAGE_SHIFT,
|
||||
page_offset, 64, &page_offset_quantized);
|
||||
if (!page_size) {
|
||||
err = -EINVAL;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
inlen = MLX5_ST_SZ_BYTES(create_sq_in) + sizeof(u64) * ncont;
|
||||
inlen = MLX5_ST_SZ_BYTES(create_sq_in) +
|
||||
sizeof(u64) *
|
||||
ib_umem_num_dma_blocks(sq->ubuffer.umem, page_size);
|
||||
in = kvzalloc(inlen, GFP_KERNEL);
|
||||
if (!in) {
|
||||
err = -ENOMEM;
|
||||
@@ -1248,11 +1230,12 @@ static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
|
||||
MLX5_SET64(wq, wq, dbr_addr, MLX5_GET64(qpc, qpc, dbr_addr));
|
||||
MLX5_SET(wq, wq, log_wq_stride, ilog2(MLX5_SEND_WQE_BB));
|
||||
MLX5_SET(wq, wq, log_wq_sz, MLX5_GET(qpc, qpc, log_sq_size));
|
||||
MLX5_SET(wq, wq, log_wq_pg_sz, page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(wq, wq, page_offset, offset);
|
||||
MLX5_SET(wq, wq, log_wq_pg_sz,
|
||||
order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(wq, wq, page_offset, page_offset_quantized);
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
|
||||
mlx5_ib_populate_pas(dev, sq->ubuffer.umem, page_shift, pas, 0);
|
||||
mlx5_ib_populate_pas(sq->ubuffer.umem, page_size, pas, 0);
|
||||
|
||||
err = mlx5_core_create_sq_tracked(dev, in, inlen, &sq->base.mqp);
|
||||
|
||||
@@ -1278,40 +1261,31 @@ static void destroy_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
|
||||
ib_umem_release(sq->ubuffer.umem);
|
||||
}
|
||||
|
||||
static size_t get_rq_pas_size(void *qpc)
|
||||
{
|
||||
u32 log_page_size = MLX5_GET(qpc, qpc, log_page_size) + 12;
|
||||
u32 log_rq_stride = MLX5_GET(qpc, qpc, log_rq_stride);
|
||||
u32 log_rq_size = MLX5_GET(qpc, qpc, log_rq_size);
|
||||
u32 page_offset = MLX5_GET(qpc, qpc, page_offset);
|
||||
u32 po_quanta = 1 << (log_page_size - 6);
|
||||
u32 rq_sz = 1 << (log_rq_size + 4 + log_rq_stride);
|
||||
u32 page_size = 1 << log_page_size;
|
||||
u32 rq_sz_po = rq_sz + (page_offset * po_quanta);
|
||||
u32 rq_num_pas = (rq_sz_po + page_size - 1) / page_size;
|
||||
|
||||
return rq_num_pas * sizeof(u64);
|
||||
}
|
||||
|
||||
static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
|
||||
struct mlx5_ib_rq *rq, void *qpin,
|
||||
size_t qpinlen, struct ib_pd *pd)
|
||||
struct ib_pd *pd)
|
||||
{
|
||||
struct mlx5_ib_qp *mqp = rq->base.container_mibqp;
|
||||
__be64 *pas;
|
||||
__be64 *qp_pas;
|
||||
void *in;
|
||||
void *rqc;
|
||||
void *wq;
|
||||
void *qpc = MLX5_ADDR_OF(create_qp_in, qpin, qpc);
|
||||
size_t rq_pas_size = get_rq_pas_size(qpc);
|
||||
struct ib_umem *umem = rq->base.ubuffer.umem;
|
||||
unsigned int page_offset_quantized;
|
||||
unsigned long page_size = 0;
|
||||
size_t inlen;
|
||||
int err;
|
||||
|
||||
if (qpinlen < rq_pas_size + MLX5_BYTE_OFF(create_qp_in, pas))
|
||||
page_size = mlx5_umem_find_best_quantized_pgoff(umem, wq, log_wq_pg_sz,
|
||||
MLX5_ADAPTER_PAGE_SHIFT,
|
||||
page_offset, 64,
|
||||
&page_offset_quantized);
|
||||
if (!page_size)
|
||||
return -EINVAL;
|
||||
|
||||
inlen = MLX5_ST_SZ_BYTES(create_rq_in) + rq_pas_size;
|
||||
inlen = MLX5_ST_SZ_BYTES(create_rq_in) +
|
||||
sizeof(u64) * ib_umem_num_dma_blocks(umem, page_size);
|
||||
in = kvzalloc(inlen, GFP_KERNEL);
|
||||
if (!in)
|
||||
return -ENOMEM;
|
||||
@@ -1333,16 +1307,16 @@ static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
|
||||
MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
|
||||
if (rq->flags & MLX5_IB_RQ_PCI_WRITE_END_PADDING)
|
||||
MLX5_SET(wq, wq, end_padding_mode, MLX5_WQ_END_PAD_MODE_ALIGN);
|
||||
MLX5_SET(wq, wq, page_offset, MLX5_GET(qpc, qpc, page_offset));
|
||||
MLX5_SET(wq, wq, page_offset, page_offset_quantized);
|
||||
MLX5_SET(wq, wq, pd, MLX5_GET(qpc, qpc, pd));
|
||||
MLX5_SET64(wq, wq, dbr_addr, MLX5_GET64(qpc, qpc, dbr_addr));
|
||||
MLX5_SET(wq, wq, log_wq_stride, MLX5_GET(qpc, qpc, log_rq_stride) + 4);
|
||||
MLX5_SET(wq, wq, log_wq_pg_sz, MLX5_GET(qpc, qpc, log_page_size));
|
||||
MLX5_SET(wq, wq, log_wq_pg_sz,
|
||||
order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT);
|
||||
MLX5_SET(wq, wq, log_wq_sz, MLX5_GET(qpc, qpc, log_rq_size));
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
|
||||
qp_pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, qpin, pas);
|
||||
memcpy(pas, qp_pas, rq_pas_size);
|
||||
mlx5_ib_populate_pas(umem, page_size, pas, 0);
|
||||
|
||||
err = mlx5_core_create_rq_tracked(dev, in, inlen, &rq->base.mqp);
|
||||
|
||||
@@ -1463,7 +1437,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
|
||||
rq->flags |= MLX5_IB_RQ_CVLAN_STRIPPING;
|
||||
if (qp->flags & IB_QP_CREATE_PCI_WRITE_END_PADDING)
|
||||
rq->flags |= MLX5_IB_RQ_PCI_WRITE_END_PADDING;
|
||||
err = create_raw_packet_qp_rq(dev, rq, in, inlen, pd);
|
||||
err = create_raw_packet_qp_rq(dev, rq, in, pd);
|
||||
if (err)
|
||||
goto err_destroy_sq;
|
||||
|
||||
@@ -2436,7 +2410,7 @@ static int create_dct(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
}
|
||||
|
||||
qp->state = IB_QPS_RESET;
|
||||
|
||||
rdma_restrack_no_track(&qp->ibqp.res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2460,6 +2434,7 @@ static int check_qp_type(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
|
||||
case IB_QPT_GSI:
|
||||
if (dev->profile == &raw_eth_profile)
|
||||
goto out;
|
||||
fallthrough;
|
||||
case IB_QPT_RAW_PACKET:
|
||||
case IB_QPT_UD:
|
||||
case MLX5_IB_QPT_REG_UMR:
|
||||
@@ -2712,11 +2687,12 @@ static int process_create_flags(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
|
||||
process_create_flag(dev, &create_flags, MLX5_IB_QP_CREATE_SQPN_QP1,
|
||||
true, qp);
|
||||
|
||||
if (create_flags)
|
||||
if (create_flags) {
|
||||
mlx5_ib_dbg(dev, "Create QP has unsupported flags 0x%X\n",
|
||||
create_flags);
|
||||
|
||||
return (create_flags) ? -EINVAL : 0;
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_udata_size(struct mlx5_ib_dev *dev,
|
||||
@@ -3102,7 +3078,7 @@ static int ib_to_mlx5_rate_map(u8 rate)
|
||||
return 5;
|
||||
default:
|
||||
return rate + MLX5_STAT_RATE_OFFSET;
|
||||
};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4247,6 +4223,9 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
int err = -EINVAL;
|
||||
int port;
|
||||
|
||||
if (attr_mask & ~(IB_QP_ATTR_STANDARD_BITS | IB_QP_RATE_LIMIT))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (ibqp->rwq_ind_tbl)
|
||||
return -ENOSYS;
|
||||
|
||||
@@ -4576,7 +4555,9 @@ static int query_qp_attr(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
|
||||
pri_path = MLX5_ADDR_OF(qpc, qpc, primary_address_path);
|
||||
alt_path = MLX5_ADDR_OF(qpc, qpc, secondary_address_path);
|
||||
|
||||
if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) {
|
||||
if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC ||
|
||||
qp->ibqp.qp_type == IB_QPT_XRC_INI ||
|
||||
qp->ibqp.qp_type == IB_QPT_XRC_TGT) {
|
||||
to_rdma_ah_attr(dev, &qp_attr->ah_attr, pri_path);
|
||||
to_rdma_ah_attr(dev, &qp_attr->alt_ah_attr, alt_path);
|
||||
qp_attr->alt_pkey_index = MLX5_GET(ads, alt_path, pkey_index);
|
||||
@@ -4882,7 +4863,7 @@ static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,
|
||||
MLX5_SET(rqc, rqc, delay_drop_en, 1);
|
||||
}
|
||||
rq_pas0 = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
|
||||
mlx5_ib_populate_pas(dev, rwq->umem, rwq->page_shift, rq_pas0, 0);
|
||||
mlx5_ib_populate_pas(rwq->umem, 1UL << rwq->page_shift, rq_pas0, 0);
|
||||
err = mlx5_core_create_rq_tracked(dev, in, inlen, &rwq->core_qp);
|
||||
if (!err && init_attr->create_flags & IB_WQ_FLAGS_DELAY_DROP) {
|
||||
err = set_delay_drop(dev);
|
||||
|
||||
@@ -116,7 +116,7 @@ static int fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr)
|
||||
{
|
||||
struct mlx5_ib_mr *mr = to_mmr(ibmr);
|
||||
|
||||
return fill_res_raw(msg, mr->dev, MLX5_SGMT_TYPE_PRM_QUERY_MKEY,
|
||||
return fill_res_raw(msg, mr_to_mdev(mr), MLX5_SGMT_TYPE_PRM_QUERY_MKEY,
|
||||
mlx5_mkey_to_idx(mr->mmkey.key));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,10 +51,6 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
|
||||
udata, struct mlx5_ib_ucontext, ibucontext);
|
||||
size_t ucmdlen;
|
||||
int err;
|
||||
int npages;
|
||||
int page_shift;
|
||||
int ncont;
|
||||
u32 offset;
|
||||
u32 uidx = MLX5_IB_DEFAULT_UIDX;
|
||||
|
||||
ucmdlen = min(udata->inlen, sizeof(ucmd));
|
||||
@@ -86,32 +82,14 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
|
||||
err = PTR_ERR(srq->umem);
|
||||
return err;
|
||||
}
|
||||
|
||||
mlx5_ib_cont_pages(srq->umem, ucmd.buf_addr, 0, &npages,
|
||||
&page_shift, &ncont, NULL);
|
||||
err = mlx5_ib_get_buf_offset(ucmd.buf_addr, page_shift,
|
||||
&offset);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "bad offset\n");
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
in->pas = kvcalloc(ncont, sizeof(*in->pas), GFP_KERNEL);
|
||||
if (!in->pas) {
|
||||
err = -ENOMEM;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
mlx5_ib_populate_pas(dev, srq->umem, page_shift, in->pas, 0);
|
||||
in->umem = srq->umem;
|
||||
|
||||
err = mlx5_ib_db_map_user(ucontext, udata, ucmd.db_addr, &srq->db);
|
||||
if (err) {
|
||||
mlx5_ib_dbg(dev, "map doorbell failed\n");
|
||||
goto err_in;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
in->page_offset = offset;
|
||||
in->uid = (in->type != IB_SRQT_XRC) ? to_mpd(pd)->uid : 0;
|
||||
if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
|
||||
in->type != IB_SRQT_BASIC)
|
||||
@@ -119,9 +97,6 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
|
||||
|
||||
return 0;
|
||||
|
||||
err_in:
|
||||
kvfree(in->pas);
|
||||
|
||||
err_umem:
|
||||
ib_umem_release(srq->umem);
|
||||
|
||||
@@ -226,6 +201,11 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq,
|
||||
struct mlx5_srq_attr in = {};
|
||||
__u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz);
|
||||
|
||||
if (init_attr->srq_type != IB_SRQT_BASIC &&
|
||||
init_attr->srq_type != IB_SRQT_XRC &&
|
||||
init_attr->srq_type != IB_SRQT_TM)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Sanity check SRQ size before proceeding */
|
||||
if (init_attr->attr.max_wr >= max_srq_wqes) {
|
||||
mlx5_ib_dbg(dev, "max_wr %d, cap %d\n",
|
||||
|
||||
@@ -28,6 +28,7 @@ struct mlx5_srq_attr {
|
||||
u32 user_index;
|
||||
u64 db_record;
|
||||
__be64 *pas;
|
||||
struct ib_umem *umem;
|
||||
u32 tm_log_list_size;
|
||||
u32 tm_next_tag;
|
||||
u32 tm_hw_phase_cnt;
|
||||
|
||||
@@ -92,6 +92,25 @@ struct mlx5_core_srq *mlx5_cmd_get_srq(struct mlx5_ib_dev *dev, u32 srqn)
|
||||
return srq;
|
||||
}
|
||||
|
||||
static int __set_srq_page_size(struct mlx5_srq_attr *in,
|
||||
unsigned long page_size)
|
||||
{
|
||||
if (!page_size)
|
||||
return -EINVAL;
|
||||
in->log_page_size = order_base_2(page_size) - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
|
||||
if (WARN_ON(get_pas_size(in) !=
|
||||
ib_umem_num_dma_blocks(in->umem, page_size) * sizeof(u64)))
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define set_srq_page_size(in, typ, log_pgsz_fld) \
|
||||
__set_srq_page_size(in, mlx5_umem_find_best_quantized_pgoff( \
|
||||
(in)->umem, typ, log_pgsz_fld, \
|
||||
MLX5_ADAPTER_PAGE_SHIFT, page_offset, \
|
||||
64, &(in)->page_offset))
|
||||
|
||||
static int create_srq_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
struct mlx5_srq_attr *in)
|
||||
{
|
||||
@@ -103,6 +122,12 @@ static int create_srq_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
int inlen;
|
||||
int err;
|
||||
|
||||
if (in->umem) {
|
||||
err = set_srq_page_size(in, srqc, log_page_size);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
pas_size = get_pas_size(in);
|
||||
inlen = MLX5_ST_SZ_BYTES(create_srq_in) + pas_size;
|
||||
create_in = kvzalloc(inlen, GFP_KERNEL);
|
||||
@@ -114,7 +139,13 @@ static int create_srq_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
pas = MLX5_ADDR_OF(create_srq_in, create_in, pas);
|
||||
|
||||
set_srqc(srqc, in);
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
if (in->umem)
|
||||
mlx5_ib_populate_pas(
|
||||
in->umem,
|
||||
1UL << (in->log_page_size + MLX5_ADAPTER_PAGE_SHIFT),
|
||||
pas, 0);
|
||||
else
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
|
||||
MLX5_SET(create_srq_in, create_in, opcode,
|
||||
MLX5_CMD_OP_CREATE_SRQ);
|
||||
@@ -194,6 +225,12 @@ static int create_xrc_srq_cmd(struct mlx5_ib_dev *dev,
|
||||
int inlen;
|
||||
int err;
|
||||
|
||||
if (in->umem) {
|
||||
err = set_srq_page_size(in, xrc_srqc, log_page_size);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
pas_size = get_pas_size(in);
|
||||
inlen = MLX5_ST_SZ_BYTES(create_xrc_srq_in) + pas_size;
|
||||
create_in = kvzalloc(inlen, GFP_KERNEL);
|
||||
@@ -207,7 +244,13 @@ static int create_xrc_srq_cmd(struct mlx5_ib_dev *dev,
|
||||
|
||||
set_srqc(xrc_srqc, in);
|
||||
MLX5_SET(xrc_srqc, xrc_srqc, user_index, in->user_index);
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
if (in->umem)
|
||||
mlx5_ib_populate_pas(
|
||||
in->umem,
|
||||
1UL << (in->log_page_size + MLX5_ADAPTER_PAGE_SHIFT),
|
||||
pas, 0);
|
||||
else
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
MLX5_SET(create_xrc_srq_in, create_in, opcode,
|
||||
MLX5_CMD_OP_CREATE_XRC_SRQ);
|
||||
|
||||
@@ -289,11 +332,18 @@ static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
void *create_in = NULL;
|
||||
void *rmpc;
|
||||
void *wq;
|
||||
void *pas;
|
||||
int pas_size;
|
||||
int outlen;
|
||||
int inlen;
|
||||
int err;
|
||||
|
||||
if (in->umem) {
|
||||
err = set_srq_page_size(in, wq, log_wq_pg_sz);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
pas_size = get_pas_size(in);
|
||||
inlen = MLX5_ST_SZ_BYTES(create_rmp_in) + pas_size;
|
||||
outlen = MLX5_ST_SZ_BYTES(create_rmp_out);
|
||||
@@ -309,8 +359,16 @@ static int create_rmp_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
|
||||
MLX5_SET(rmpc, rmpc, state, MLX5_RMPC_STATE_RDY);
|
||||
MLX5_SET(create_rmp_in, create_in, uid, in->uid);
|
||||
pas = MLX5_ADDR_OF(rmpc, rmpc, wq.pas);
|
||||
|
||||
set_wq(wq, in);
|
||||
memcpy(MLX5_ADDR_OF(rmpc, rmpc, wq.pas), in->pas, pas_size);
|
||||
if (in->umem)
|
||||
mlx5_ib_populate_pas(
|
||||
in->umem,
|
||||
1UL << (in->log_page_size + MLX5_ADAPTER_PAGE_SHIFT),
|
||||
pas, 0);
|
||||
else
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
|
||||
MLX5_SET(create_rmp_in, create_in, opcode, MLX5_CMD_OP_CREATE_RMP);
|
||||
err = mlx5_cmd_exec(dev->mdev, create_in, inlen, create_out, outlen);
|
||||
@@ -421,10 +479,17 @@ static int create_xrq_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
void *create_in;
|
||||
void *xrqc;
|
||||
void *wq;
|
||||
void *pas;
|
||||
int pas_size;
|
||||
int inlen;
|
||||
int err;
|
||||
|
||||
if (in->umem) {
|
||||
err = set_srq_page_size(in, wq, log_wq_pg_sz);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
pas_size = get_pas_size(in);
|
||||
inlen = MLX5_ST_SZ_BYTES(create_xrq_in) + pas_size;
|
||||
create_in = kvzalloc(inlen, GFP_KERNEL);
|
||||
@@ -433,9 +498,16 @@ static int create_xrq_cmd(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
|
||||
|
||||
xrqc = MLX5_ADDR_OF(create_xrq_in, create_in, xrq_context);
|
||||
wq = MLX5_ADDR_OF(xrqc, xrqc, wq);
|
||||
pas = MLX5_ADDR_OF(xrqc, xrqc, wq.pas);
|
||||
|
||||
set_wq(wq, in);
|
||||
memcpy(MLX5_ADDR_OF(xrqc, xrqc, wq.pas), in->pas, pas_size);
|
||||
if (in->umem)
|
||||
mlx5_ib_populate_pas(
|
||||
in->umem,
|
||||
1UL << (in->log_page_size + MLX5_ADAPTER_PAGE_SHIFT),
|
||||
pas, 0);
|
||||
else
|
||||
memcpy(pas, in->pas, pas_size);
|
||||
|
||||
if (in->type == IB_SRQT_TM) {
|
||||
MLX5_SET(xrqc, xrqc, topology, MLX5_XRQC_TOPOLOGY_TAG_MATCHING);
|
||||
|
||||
@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev,
|
||||
entry->byte_len = MTHCA_ATOMIC_BYTE_LEN;
|
||||
break;
|
||||
default:
|
||||
entry->opcode = MTHCA_OPCODE_INVALID;
|
||||
entry->opcode = 0xFF;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -105,7 +105,6 @@ enum {
|
||||
MTHCA_OPCODE_ATOMIC_CS = 0x11,
|
||||
MTHCA_OPCODE_ATOMIC_FA = 0x12,
|
||||
MTHCA_OPCODE_BIND_MW = 0x18,
|
||||
MTHCA_OPCODE_INVALID = 0xff
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -470,7 +470,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
|
||||
int err;
|
||||
|
||||
if (init_attr->create_flags)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
switch (init_attr->qp_type) {
|
||||
case IB_QPT_RC:
|
||||
@@ -612,7 +612,7 @@ static int mthca_create_cq(struct ib_cq *ibcq,
|
||||
udata, struct mthca_ucontext, ibucontext);
|
||||
|
||||
if (attr->flags)
|
||||
return -EINVAL;
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
|
||||
return -EINVAL;
|
||||
@@ -961,29 +961,34 @@ static ssize_t hw_rev_show(struct device *device,
|
||||
struct mthca_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%x\n", dev->rev_id);
|
||||
return sysfs_emit(buf, "%x\n", dev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
static const char *hca_type_string(int hca_type)
|
||||
{
|
||||
switch (hca_type) {
|
||||
case PCI_DEVICE_ID_MELLANOX_TAVOR:
|
||||
return "MT23108";
|
||||
case PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT:
|
||||
return "MT25208 (MT23108 compat mode)";
|
||||
case PCI_DEVICE_ID_MELLANOX_ARBEL:
|
||||
return "MT25208";
|
||||
case PCI_DEVICE_ID_MELLANOX_SINAI:
|
||||
case PCI_DEVICE_ID_MELLANOX_SINAI_OLD:
|
||||
return "MT25204";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static ssize_t hca_type_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mthca_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
switch (dev->pdev->device) {
|
||||
case PCI_DEVICE_ID_MELLANOX_TAVOR:
|
||||
return sprintf(buf, "MT23108\n");
|
||||
case PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT:
|
||||
return sprintf(buf, "MT25208 (MT23108 compat mode)\n");
|
||||
case PCI_DEVICE_ID_MELLANOX_ARBEL:
|
||||
return sprintf(buf, "MT25208\n");
|
||||
case PCI_DEVICE_ID_MELLANOX_SINAI:
|
||||
case PCI_DEVICE_ID_MELLANOX_SINAI_OLD:
|
||||
return sprintf(buf, "MT25204\n");
|
||||
default:
|
||||
return sprintf(buf, "unknown\n");
|
||||
}
|
||||
return sysfs_emit(buf, "%s\n", hca_type_string(dev->pdev->device));
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -993,7 +998,7 @@ static ssize_t board_id_show(struct device *device,
|
||||
struct mthca_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
|
||||
return sysfs_emit(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
||||
@@ -1158,36 +1163,12 @@ int mthca_register_device(struct mthca_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dev->ib_dev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
|
||||
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
|
||||
(1ull << IB_USER_VERBS_CMD_REG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
|
||||
(1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
|
||||
(1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
|
||||
dev->ib_dev.node_type = RDMA_NODE_IB_CA;
|
||||
dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
|
||||
dev->ib_dev.num_comp_vectors = 1;
|
||||
dev->ib_dev.dev.parent = &dev->pdev->dev;
|
||||
|
||||
if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
|
||||
dev->ib_dev.uverbs_cmd_mask |=
|
||||
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
|
||||
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
|
||||
|
||||
if (mthca_is_memfree(dev))
|
||||
ib_set_device_ops(&dev->ib_dev,
|
||||
&mthca_dev_arbel_srq_ops);
|
||||
|
||||
@@ -863,6 +863,9 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
|
||||
enum ib_qp_state cur_state, new_state;
|
||||
int err = -EINVAL;
|
||||
|
||||
if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
mutex_lock(&qp->mutex);
|
||||
if (attr_mask & IB_QP_CUR_STATE) {
|
||||
cur_state = attr->cur_qp_state;
|
||||
|
||||
@@ -119,7 +119,7 @@ static ssize_t hw_rev_show(struct device *device,
|
||||
struct ocrdma_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct ocrdma_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%x\n", dev->nic_info.pdev->vendor);
|
||||
return sysfs_emit(buf, "0x%x\n", dev->nic_info.pdev->vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
||||
@@ -129,7 +129,7 @@ static ssize_t hca_type_show(struct device *device,
|
||||
struct ocrdma_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct ocrdma_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->model_number[0]);
|
||||
return sysfs_emit(buf, "%s\n", &dev->model_number[0]);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
||||
@@ -154,6 +154,7 @@ static const struct ib_device_ops ocrdma_dev_ops = {
|
||||
.create_ah = ocrdma_create_ah,
|
||||
.create_cq = ocrdma_create_cq,
|
||||
.create_qp = ocrdma_create_qp,
|
||||
.create_user_ah = ocrdma_create_ah,
|
||||
.dealloc_pd = ocrdma_dealloc_pd,
|
||||
.dealloc_ucontext = ocrdma_dealloc_ucontext,
|
||||
.dereg_mr = ocrdma_dereg_mr,
|
||||
@@ -204,32 +205,6 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
|
||||
BUILD_BUG_ON(sizeof(OCRDMA_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX);
|
||||
memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
|
||||
sizeof(OCRDMA_NODE_DESC));
|
||||
dev->ibdev.uverbs_cmd_mask =
|
||||
OCRDMA_UVERBS(GET_CONTEXT) |
|
||||
OCRDMA_UVERBS(QUERY_DEVICE) |
|
||||
OCRDMA_UVERBS(QUERY_PORT) |
|
||||
OCRDMA_UVERBS(ALLOC_PD) |
|
||||
OCRDMA_UVERBS(DEALLOC_PD) |
|
||||
OCRDMA_UVERBS(REG_MR) |
|
||||
OCRDMA_UVERBS(DEREG_MR) |
|
||||
OCRDMA_UVERBS(CREATE_COMP_CHANNEL) |
|
||||
OCRDMA_UVERBS(CREATE_CQ) |
|
||||
OCRDMA_UVERBS(RESIZE_CQ) |
|
||||
OCRDMA_UVERBS(DESTROY_CQ) |
|
||||
OCRDMA_UVERBS(REQ_NOTIFY_CQ) |
|
||||
OCRDMA_UVERBS(CREATE_QP) |
|
||||
OCRDMA_UVERBS(MODIFY_QP) |
|
||||
OCRDMA_UVERBS(QUERY_QP) |
|
||||
OCRDMA_UVERBS(DESTROY_QP) |
|
||||
OCRDMA_UVERBS(POLL_CQ) |
|
||||
OCRDMA_UVERBS(POST_SEND) |
|
||||
OCRDMA_UVERBS(POST_RECV);
|
||||
|
||||
dev->ibdev.uverbs_cmd_mask |=
|
||||
OCRDMA_UVERBS(CREATE_AH) |
|
||||
OCRDMA_UVERBS(MODIFY_AH) |
|
||||
OCRDMA_UVERBS(QUERY_AH) |
|
||||
OCRDMA_UVERBS(DESTROY_AH);
|
||||
|
||||
dev->ibdev.node_type = RDMA_NODE_IB_CA;
|
||||
dev->ibdev.phys_port_cnt = 1;
|
||||
@@ -240,16 +215,9 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
|
||||
|
||||
ib_set_device_ops(&dev->ibdev, &ocrdma_dev_ops);
|
||||
|
||||
if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R) {
|
||||
dev->ibdev.uverbs_cmd_mask |=
|
||||
OCRDMA_UVERBS(CREATE_SRQ) |
|
||||
OCRDMA_UVERBS(MODIFY_SRQ) |
|
||||
OCRDMA_UVERBS(QUERY_SRQ) |
|
||||
OCRDMA_UVERBS(DESTROY_SRQ) |
|
||||
OCRDMA_UVERBS(POST_SRQ_RECV);
|
||||
|
||||
if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R)
|
||||
ib_set_device_ops(&dev->ibdev, &ocrdma_dev_srq_ops);
|
||||
}
|
||||
|
||||
rdma_set_device_sysfs_group(&dev->ibdev, &ocrdma_attr_group);
|
||||
ret = ib_device_set_netdev(&dev->ibdev, dev->nic_info.netdev, 1);
|
||||
if (ret)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user