net/mlx5_core: Add transport domain alloc/dealloc support
authorAchiad Shochat <achiad@mellanox.com>
Thu, 11 Jun 2015 11:47:32 +0000 (14:47 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Jun 2015 22:55:26 +0000 (15:55 -0700)
Each transport object, namely TIR and TIS, must have a transport domain
number (TDN) identifier.

The driver wrongly assumed that it is OK to use TDN=0 without explicit
TDN allocation from the device.

The TDN will also be used for isolating different processes once user
mode Ethernet will be supported.

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/transobj.c
drivers/net/ethernet/mellanox/mlx5/core/transobj.h

index 7a120283de2c9d04b2a0c903e374b692fc97d85a..8d98b03026d5db588eee7de23f04611f268b4543 100644 (file)
 #include "mlx5_core.h"
 #include "transobj.h"
 
+int mlx5_alloc_transport_domain(struct mlx5_core_dev *dev, u32 *tdn)
+{
+       u32 in[MLX5_ST_SZ_DW(alloc_transport_domain_in)];
+       u32 out[MLX5_ST_SZ_DW(alloc_transport_domain_out)];
+       int err;
+
+       memset(in, 0, sizeof(in));
+       memset(out, 0, sizeof(out));
+
+       MLX5_SET(alloc_transport_domain_in, in, opcode,
+                MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN);
+
+       err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, sizeof(out));
+       if (!err)
+               *tdn = MLX5_GET(alloc_transport_domain_out, out,
+                               transport_domain);
+
+       return err;
+}
+
+void mlx5_dealloc_transport_domain(struct mlx5_core_dev *dev, u32 tdn)
+{
+       u32 in[MLX5_ST_SZ_DW(dealloc_transport_domain_in)];
+       u32 out[MLX5_ST_SZ_DW(dealloc_transport_domain_out)];
+
+       memset(in, 0, sizeof(in));
+       memset(out, 0, sizeof(out));
+
+       MLX5_SET(dealloc_transport_domain_in, in, opcode,
+                MLX5_CMD_OP_DEALLOC_TRANSPORT_DOMAIN);
+       MLX5_SET(dealloc_transport_domain_in, in, transport_domain, tdn);
+
+       mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, sizeof(out));
+}
+
 int mlx5_core_create_rq(struct mlx5_core_dev *dev, u32 *in, int inlen, u32 *rqn)
 {
        u32 out[MLX5_ST_SZ_DW(create_rq_out)];
index 90322c11361f1ef14ca0565e3acb57203e78b7f1..f9ef244710d534b5e22bddd313d1497b36da12fa 100644 (file)
@@ -33,6 +33,8 @@
 #ifndef __TRANSOBJ_H__
 #define __TRANSOBJ_H__
 
+int mlx5_alloc_transport_domain(struct mlx5_core_dev *dev, u32 *tdn);
+void mlx5_dealloc_transport_domain(struct mlx5_core_dev *dev, u32 tdn);
 int mlx5_core_create_rq(struct mlx5_core_dev *dev, u32 *in, int inlen,
                        u32 *rqn);
 int mlx5_core_modify_rq(struct mlx5_core_dev *dev, u32 rqn, u32 *in, int inlen);