The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/mlx5/mlx5_core/mlx5_transobj.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
   10  *    notice, this list of conditions and the following disclaimer in the
   11  *    documentation and/or other materials provided with the distribution.
   12  *
   13  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
   14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   16  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
   17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   23  * SUCH DAMAGE.
   24  *
   25  * $FreeBSD$
   26  */
   27 
   28 #include "opt_rss.h"
   29 #include "opt_ratelimit.h"
   30 
   31 #include <dev/mlx5/driver.h>
   32 #include <dev/mlx5/mlx5_core/mlx5_core.h>
   33 #include <dev/mlx5/mlx5_core/transobj.h>
   34 
   35 int mlx5_alloc_transport_domain(struct mlx5_core_dev *dev, u32 *tdn, u32 uid)
   36 {
   37         u32 in[MLX5_ST_SZ_DW(alloc_transport_domain_in)] = {0};
   38         u32 out[MLX5_ST_SZ_DW(alloc_transport_domain_out)] = {0};
   39         int err;
   40 
   41         MLX5_SET(alloc_transport_domain_in, in, opcode,
   42                  MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN);
   43         MLX5_SET(alloc_transport_domain_in, in, uid, uid);
   44 
   45         err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
   46         if (!err)
   47                 *tdn = MLX5_GET(alloc_transport_domain_out, out,
   48                                 transport_domain);
   49 
   50         return err;
   51 }
   52 
   53 void mlx5_dealloc_transport_domain(struct mlx5_core_dev *dev, u32 tdn, u32 uid)
   54 {
   55         u32 in[MLX5_ST_SZ_DW(dealloc_transport_domain_in)] = {0};
   56         u32 out[MLX5_ST_SZ_DW(dealloc_transport_domain_out)] = {0};
   57 
   58         MLX5_SET(dealloc_transport_domain_in, in, opcode,
   59                  MLX5_CMD_OP_DEALLOC_TRANSPORT_DOMAIN);
   60         MLX5_SET(dealloc_transport_domain_in, in, transport_domain, tdn);
   61         MLX5_SET(dealloc_transport_domain_in, in, uid, uid);
   62 
   63         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
   64 }
   65 
   66 int mlx5_core_create_rq(struct mlx5_core_dev *dev, u32 *in, int inlen, u32 *rqn)
   67 {
   68         u32 out[MLX5_ST_SZ_DW(create_rq_out)] = {0};
   69         int err;
   70 
   71         MLX5_SET(create_rq_in, in, opcode, MLX5_CMD_OP_CREATE_RQ);
   72 
   73         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
   74         if (!err)
   75                 *rqn = MLX5_GET(create_rq_out, out, rqn);
   76 
   77         return err;
   78 }
   79 
   80 int mlx5_core_modify_rq(struct mlx5_core_dev *dev, u32 *in, int inlen)
   81 {
   82         u32 out[MLX5_ST_SZ_DW(modify_rq_out)] = {0};
   83 
   84         MLX5_SET(modify_rq_in, in, opcode, MLX5_CMD_OP_MODIFY_RQ);
   85 
   86         return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
   87 }
   88 
   89 void mlx5_core_destroy_rq(struct mlx5_core_dev *dev, u32 rqn)
   90 {
   91         u32 in[MLX5_ST_SZ_DW(destroy_rq_in)] = {0};
   92         u32 out[MLX5_ST_SZ_DW(destroy_rq_out)] = {0};
   93 
   94         MLX5_SET(destroy_rq_in, in, opcode, MLX5_CMD_OP_DESTROY_RQ);
   95         MLX5_SET(destroy_rq_in, in, rqn, rqn);
   96 
   97         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
   98 }
   99 
  100 int mlx5_core_query_rq(struct mlx5_core_dev *dev, u32 rqn, u32 *out)
  101 {
  102         u32 in[MLX5_ST_SZ_DW(query_rq_in)] = {0};
  103         int outlen = MLX5_ST_SZ_BYTES(query_rq_out);
  104 
  105         MLX5_SET(query_rq_in, in, opcode, MLX5_CMD_OP_QUERY_RQ);
  106         MLX5_SET(query_rq_in, in, rqn, rqn);
  107 
  108         return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
  109 }
  110 
  111 int mlx5_core_create_sq(struct mlx5_core_dev *dev, u32 *in, int inlen, u32 *sqn)
  112 {
  113         u32 out[MLX5_ST_SZ_DW(create_sq_out)] = {0};
  114         int err;
  115 
  116         MLX5_SET(create_sq_in, in, opcode, MLX5_CMD_OP_CREATE_SQ);
  117 
  118         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  119         if (!err)
  120                 *sqn = MLX5_GET(create_sq_out, out, sqn);
  121 
  122         return err;
  123 }
  124 
  125 int mlx5_core_modify_sq(struct mlx5_core_dev *dev, u32 *in, int inlen)
  126 {
  127         u32 out[MLX5_ST_SZ_DW(modify_sq_out)] = {0};
  128 
  129         MLX5_SET(modify_sq_in, in, opcode, MLX5_CMD_OP_MODIFY_SQ);
  130 
  131         return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  132 }
  133 
  134 void mlx5_core_destroy_sq(struct mlx5_core_dev *dev, u32 sqn)
  135 {
  136         u32 in[MLX5_ST_SZ_DW(destroy_sq_in)] = {0};
  137         u32 out[MLX5_ST_SZ_DW(destroy_sq_out)] = {0};
  138 
  139         MLX5_SET(destroy_sq_in, in, opcode, MLX5_CMD_OP_DESTROY_SQ);
  140         MLX5_SET(destroy_sq_in, in, sqn, sqn);
  141 
  142         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  143 }
  144 
  145 int mlx5_core_query_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *out)
  146 {
  147         u32 in[MLX5_ST_SZ_DW(query_sq_in)] = {0};
  148         int outlen = MLX5_ST_SZ_BYTES(query_sq_out);
  149 
  150         MLX5_SET(query_sq_in, in, opcode, MLX5_CMD_OP_QUERY_SQ);
  151         MLX5_SET(query_sq_in, in, sqn, sqn);
  152 
  153         return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
  154 }
  155 
  156 int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen,
  157                          u32 *tirn)
  158 {
  159         u32 out[MLX5_ST_SZ_DW(create_tir_out)] = {0};
  160         int err;
  161 
  162         MLX5_SET(create_tir_in, in, opcode, MLX5_CMD_OP_CREATE_TIR);
  163 
  164         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  165         if (!err)
  166                 *tirn = MLX5_GET(create_tir_out, out, tirn);
  167 
  168         return err;
  169 }
  170 
  171 void mlx5_core_destroy_tir(struct mlx5_core_dev *dev, u32 tirn, u32 uid)
  172 {
  173         u32 in[MLX5_ST_SZ_DW(destroy_tir_in)] = {0};
  174         u32 out[MLX5_ST_SZ_DW(destroy_tir_out)] = {0};
  175 
  176         MLX5_SET(destroy_tir_in, in, opcode, MLX5_CMD_OP_DESTROY_TIR);
  177         MLX5_SET(destroy_tir_in, in, uid, uid);
  178         MLX5_SET(destroy_tir_in, in, tirn, tirn);
  179 
  180         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  181 }
  182 
  183 int mlx5_core_create_tis(struct mlx5_core_dev *dev, u32 *in, int inlen,
  184                          u32 *tisn)
  185 {
  186         u32 out[MLX5_ST_SZ_DW(create_tis_out)] = {0};
  187         int err;
  188 
  189         MLX5_SET(create_tis_in, in, opcode, MLX5_CMD_OP_CREATE_TIS);
  190 
  191         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  192         if (!err)
  193                 *tisn = MLX5_GET(create_tis_out, out, tisn);
  194 
  195         return err;
  196 }
  197 
  198 int mlx5_core_modify_tis(struct mlx5_core_dev *dev, u32 tisn, u32 *in,
  199                          int inlen)
  200 {
  201         u32 out[MLX5_ST_SZ_DW(modify_tis_out)] = {0};
  202 
  203         MLX5_SET(modify_tis_in, in, tisn, tisn);
  204         MLX5_SET(modify_tis_in, in, opcode, MLX5_CMD_OP_MODIFY_TIS);
  205 
  206         return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  207 }
  208 
  209 void mlx5_core_destroy_tis(struct mlx5_core_dev *dev, u32 tisn, u32 uid)
  210 {
  211         u32 in[MLX5_ST_SZ_DW(destroy_tis_in)] = {0};
  212         u32 out[MLX5_ST_SZ_DW(destroy_tis_out)] = {0};
  213 
  214         MLX5_SET(destroy_tis_in, in, opcode, MLX5_CMD_OP_DESTROY_TIS);
  215         MLX5_SET(destroy_tis_in, in, uid, uid);
  216         MLX5_SET(destroy_tis_in, in, tisn, tisn);
  217 
  218         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  219 }
  220 
  221 int mlx5_core_create_rmp(struct mlx5_core_dev *dev, u32 *in, int inlen, u32 *rmpn)
  222 {
  223         u32 out[MLX5_ST_SZ_DW(create_rmp_out)] = {0};
  224         int err;
  225 
  226         MLX5_SET(create_rmp_in, in, opcode, MLX5_CMD_OP_CREATE_RMP);
  227 
  228         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  229         if (!err)
  230                 *rmpn = MLX5_GET(create_rmp_out, out, rmpn);
  231 
  232         return err;
  233 }
  234 
  235 int mlx5_core_modify_rmp(struct mlx5_core_dev *dev, u32 *in, int inlen)
  236 {
  237         u32 out[MLX5_ST_SZ_DW(modify_rmp_out)] = {0};
  238 
  239         MLX5_SET(modify_rmp_in, in, opcode, MLX5_CMD_OP_MODIFY_RMP);
  240 
  241         return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  242 }
  243 
  244 int mlx5_core_destroy_rmp(struct mlx5_core_dev *dev, u32 rmpn)
  245 {
  246         u32 in[MLX5_ST_SZ_DW(destroy_rmp_in)] = {0};
  247         u32 out[MLX5_ST_SZ_DW(destroy_rmp_out)] = {0};
  248 
  249         MLX5_SET(destroy_rmp_in, in, opcode, MLX5_CMD_OP_DESTROY_RMP);
  250         MLX5_SET(destroy_rmp_in, in, rmpn, rmpn);
  251 
  252         return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  253 }
  254 
  255 int mlx5_core_query_rmp(struct mlx5_core_dev *dev, u32 rmpn, u32 *out)
  256 {
  257         u32 in[MLX5_ST_SZ_DW(query_rmp_in)] = {0};
  258         int outlen = MLX5_ST_SZ_BYTES(query_rmp_out);
  259 
  260         MLX5_SET(query_rmp_in, in, opcode, MLX5_CMD_OP_QUERY_RMP);
  261         MLX5_SET(query_rmp_in, in, rmpn,   rmpn);
  262 
  263         return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
  264 }
  265 
  266 int mlx5_core_arm_rmp(struct mlx5_core_dev *dev, u32 rmpn, u16 lwm)
  267 {
  268         void *in;
  269         void *rmpc;
  270         void *wq;
  271         void *bitmask;
  272         int  err;
  273 
  274         in = mlx5_vzalloc(MLX5_ST_SZ_BYTES(modify_rmp_in));
  275         if (!in)
  276                 return -ENOMEM;
  277 
  278         rmpc    = MLX5_ADDR_OF(modify_rmp_in,   in,   ctx);
  279         bitmask = MLX5_ADDR_OF(modify_rmp_in,   in,   bitmask);
  280         wq      = MLX5_ADDR_OF(rmpc,            rmpc, wq);
  281 
  282         MLX5_SET(modify_rmp_in, in,      rmp_state, MLX5_RMPC_STATE_RDY);
  283         MLX5_SET(modify_rmp_in, in,      rmpn,      rmpn);
  284         MLX5_SET(wq,            wq,      lwm,       lwm);
  285         MLX5_SET(rmp_bitmask,   bitmask, lwm,       1);
  286         MLX5_SET(rmpc,          rmpc,    state,     MLX5_RMPC_STATE_RDY);
  287 
  288         err =  mlx5_core_modify_rmp(dev, in, MLX5_ST_SZ_BYTES(modify_rmp_in));
  289 
  290         kvfree(in);
  291 
  292         return err;
  293 }
  294 
  295 int mlx5_core_create_xsrq(struct mlx5_core_dev *dev, u32 *in, int inlen, u32 *xsrqn)
  296 {
  297         u32 out[MLX5_ST_SZ_DW(create_xrc_srq_out)] = {0};
  298         int err;
  299 
  300         MLX5_SET(create_xrc_srq_in, in, opcode,     MLX5_CMD_OP_CREATE_XRC_SRQ);
  301 
  302         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  303         if (!err)
  304                 *xsrqn = MLX5_GET(create_xrc_srq_out, out, xrc_srqn);
  305 
  306         return err;
  307 }
  308 
  309 int mlx5_core_destroy_xsrq(struct mlx5_core_dev *dev, u32 xsrqn)
  310 {
  311         u32 in[MLX5_ST_SZ_DW(destroy_xrc_srq_in)] = {0};
  312         u32 out[MLX5_ST_SZ_DW(destroy_xrc_srq_out)] = {0};
  313 
  314         MLX5_SET(destroy_xrc_srq_in, in, opcode,   MLX5_CMD_OP_DESTROY_XRC_SRQ);
  315         MLX5_SET(destroy_xrc_srq_in, in, xrc_srqn, xsrqn);
  316 
  317         return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  318 }
  319 
  320 int mlx5_core_query_xsrq(struct mlx5_core_dev *dev, u32 xsrqn, u32 *out)
  321 {
  322         int outlen = MLX5_ST_SZ_BYTES(query_xrc_srq_out);
  323         u32 in[MLX5_ST_SZ_DW(query_xrc_srq_in)] = {0};
  324         void *xrc_srqc;
  325         void *srqc;
  326         int err;
  327 
  328         MLX5_SET(query_xrc_srq_in, in, opcode,   MLX5_CMD_OP_QUERY_XRC_SRQ);
  329         MLX5_SET(query_xrc_srq_in, in, xrc_srqn, xsrqn);
  330 
  331         err =  mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
  332         if (!err) {
  333                 xrc_srqc = MLX5_ADDR_OF(query_xrc_srq_out, out,
  334                                         xrc_srq_context_entry);
  335                 srqc = MLX5_ADDR_OF(query_srq_out, out, srq_context_entry);
  336                 memcpy(srqc, xrc_srqc, MLX5_ST_SZ_BYTES(srqc));
  337         }
  338 
  339         return err;
  340 }
  341 
  342 int mlx5_core_arm_xsrq(struct mlx5_core_dev *dev, u32 xsrqn, u16 lwm)
  343 {
  344         u32 in[MLX5_ST_SZ_DW(arm_xrc_srq_in)] = {0};
  345         u32 out[MLX5_ST_SZ_DW(arm_xrc_srq_out)] = {0};
  346 
  347         MLX5_SET(arm_xrc_srq_in, in, opcode,   MLX5_CMD_OP_ARM_XRC_SRQ);
  348         MLX5_SET(arm_xrc_srq_in, in, xrc_srqn, xsrqn);
  349         MLX5_SET(arm_xrc_srq_in, in, lwm,      lwm);
  350         MLX5_SET(arm_xrc_srq_in, in, op_mod,
  351                  MLX5_ARM_XRC_SRQ_IN_OP_MOD_XRC_SRQ);
  352 
  353         return  mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  354 
  355 }
  356 
  357 int mlx5_core_create_rqt(struct mlx5_core_dev *dev, u32 *in, int inlen,
  358                          u32 *rqtn)
  359 {
  360         u32 out[MLX5_ST_SZ_DW(create_rqt_out)] = {0};
  361         int err;
  362 
  363         MLX5_SET(create_rqt_in, in, opcode, MLX5_CMD_OP_CREATE_RQT);
  364 
  365         err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  366         if (!err)
  367                 *rqtn = MLX5_GET(create_rqt_out, out, rqtn);
  368 
  369         return err;
  370 }
  371 
  372 int mlx5_core_modify_rqt(struct mlx5_core_dev *dev, u32 rqtn, u32 *in,
  373                          int inlen)
  374 {
  375         u32 out[MLX5_ST_SZ_DW(modify_rqt_out)] = {0};
  376 
  377         MLX5_SET(modify_rqt_in, in, rqtn, rqtn);
  378         MLX5_SET(modify_rqt_in, in, opcode, MLX5_CMD_OP_MODIFY_RQT);
  379 
  380         return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
  381 }
  382 
  383 void mlx5_core_destroy_rqt(struct mlx5_core_dev *dev, u32 rqtn, u32 uid)
  384 {
  385         u32 in[MLX5_ST_SZ_DW(destroy_rqt_in)] = {0};
  386         u32 out[MLX5_ST_SZ_DW(destroy_rqt_out)] = {0};
  387 
  388         MLX5_SET(destroy_rqt_in, in, opcode, MLX5_CMD_OP_DESTROY_RQT);
  389         MLX5_SET(destroy_rqt_in, in, uid, uid);
  390         MLX5_SET(destroy_rqt_in, in, rqtn, rqtn);
  391 
  392         mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
  393 }

Cache object: 05377425d693b1c1d35c6fff1ac36ca3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.