rdma: add option to specify inteface name 86/18586/2
authorDamjan Marion <damarion@cisco.com>
Thu, 28 Mar 2019 22:34:56 +0000 (23:34 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 29 Mar 2019 00:23:57 +0000 (00:23 +0000)
Change-Id: Ic6244511b88bdd42756f74e3163a70b8014e8547
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/rdma/cli.c
src/plugins/rdma/device.c
src/plugins/rdma/format.c
src/plugins/rdma/rdma.h

index 8919603..e1ccbb6 100644 (file)
@@ -41,7 +41,9 @@ rdma_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (line_input, "name %s", &args.ifname))
+      if (unformat (line_input, "host-if %s", &args.ifname))
+       ;
+      else if (unformat (line_input, "name %s", &args.name))
        ;
       else
        return clib_error_return (0, "unknown input `%U'",
@@ -52,6 +54,7 @@ rdma_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
   rdma_create_if (vm, &args);
 
   vec_free (args.ifname);
+  vec_free (args.name);
 
   return args.error;
 }
@@ -59,7 +62,7 @@ rdma_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
 /* *INDENT-OFF* */
 VLIB_CLI_COMMAND (rdma_create_command, static) = {
   .path = "create interface rdma",
-  .short_help = "create interface rdma <name ifname>",
+  .short_help = "create interface rdma <host-if ifname> [name <name>]",
   .function = rdma_create_command_fn,
 };
 /* *INDENT-ON* */
index 31112a9..4098d3c 100644 (file)
@@ -248,6 +248,7 @@ rdma_dev_cleanup (rdma_device_t * rd)
 
   vec_free (rd->rxqs);
   vec_free (rd->txqs);
+  vec_free (rd->name);
   pool_put (rm->devices, rd);
 }
 
@@ -430,6 +431,7 @@ rdma_create_if (vlib_main_t * vm, rdma_create_if_args_t * args)
   pool_get_zero (rm->devices, rd);
   rd->dev_instance = rd - rm->devices;
   rd->per_interface_next_index = ~0;
+  rd->name = vec_dup (args->name);
 
   /* check if device exist and if it is bound to mlx5_core */
   s = format (s, "/sys/class/net/%s/device/driver/module%c", args->ifname, 0);
index 7ef65d4..fbd4067 100644 (file)
@@ -29,6 +29,9 @@ format_rdma_device_name (u8 * s, va_list * args)
   rdma_main_t *rm = &rdma_main;
   rdma_device_t *rd = vec_elt_at_index (rm->devices, i);
 
+  if (rd->name)
+    return format (s, "%s", rd->name);
+
   s = format (s, "rdma-%u", rd->dev_instance);
   return s;
 }
index 860ddab..1290153 100644 (file)
@@ -73,6 +73,7 @@ typedef struct
 
   u8 hwaddr[6];
   vlib_pci_addr_t pci_addr;
+  u8 *name;
 
   struct ibv_context *ctx;
   struct ibv_pd *pd;
@@ -95,6 +96,7 @@ extern rdma_main_t rdma_main;
 typedef struct
 {
   u8 *ifname;
+  u8 *name;
 
   /* return */
   int rv;