aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c107
-rw-r--r--src/vnet/bonding/bond.api45
-rw-r--r--src/vnet/bonding/bond_api.c34
-rw-r--r--src/vpp/api/custom_dump.c26
4 files changed, 208 insertions, 4 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index bbe5a04df33..f1935dee33a 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1932,6 +1932,41 @@ static void vl_api_bond_create_reply_t_handler_json
}
static void
+vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ i32 retval = ntohl (mp->retval);
+
+ if (vam->async_mode)
+ {
+ vam->async_errors += (retval < 0);
+ }
+ else
+ {
+ vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
+ }
+}
+
+static void vl_api_bond_create2_reply_t_handler_json
+ (vl_api_bond_create2_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t node;
+
+ vat_json_init_object (&node);
+ vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
+
+ vat_json_print (vam->ofp, &node);
+ vat_json_free (&node);
+
+ vam->retval = ntohl (mp->retval);
+ vam->result_ready = 1;
+}
+
+static void
vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
{
vat_main_t *vam = &vat_main;
@@ -5281,6 +5316,7 @@ _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
_(BOND_CREATE_REPLY, bond_create_reply) \
+_(BOND_CREATE2_REPLY, bond_create2_reply) \
_(BOND_DELETE_REPLY, bond_delete_reply) \
_(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
_(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
@@ -7770,6 +7806,73 @@ api_bond_create (vat_main_t * vam)
}
static int
+api_bond_create2 (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_bond_create2_t *mp;
+ u8 mac_address[6];
+ u8 custom_mac = 0;
+ int ret;
+ u8 mode;
+ u8 lb;
+ u8 mode_is_set = 0;
+ u32 id = ~0;
+ u8 numa_only = 0;
+ u8 gso = 0;
+
+ clib_memset (mac_address, 0, sizeof (mac_address));
+ lb = BOND_LB_L2;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "mode %U", unformat_bond_mode, &mode))
+ mode_is_set = 1;
+ else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
+ && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
+ ;
+ else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
+ mac_address))
+ custom_mac = 1;
+ else if (unformat (i, "numa-only"))
+ numa_only = 1;
+ else if (unformat (i, "gso"))
+ gso = 1;
+ else if (unformat (i, "id %u", &id))
+ ;
+ else
+ break;
+ }
+
+ if (mode_is_set == 0)
+ {
+ errmsg ("Missing bond mode. ");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M (BOND_CREATE2, mp);
+
+ mp->use_custom_mac = custom_mac;
+
+ mp->mode = htonl (mode);
+ mp->lb = htonl (lb);
+ mp->id = htonl (id);
+ mp->numa_only = numa_only;
+ mp->enable_gso = gso;
+
+ if (custom_mac)
+ clib_memcpy (mp->mac_address, mac_address, 6);
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
api_bond_delete (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
@@ -20716,6 +20819,10 @@ _(bond_create, \
"[hw-addr <mac-addr>] {round-robin | active-backup | " \
"broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
"[id <if-id>]") \
+_(bond_create2, \
+ "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
+ "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
+ "[id <if-id>] [gso]") \
_(bond_delete, \
"<vpp-if-name> | sw_if_index <id>") \
_(bond_add_member, \
diff --git a/src/vnet/bonding/bond.api b/src/vnet/bonding/bond.api
index 682298e9084..3a882b4f172 100644
--- a/src/vnet/bonding/bond.api
+++ b/src/vnet/bonding/bond.api
@@ -55,6 +55,7 @@ enum bond_lb_algo
*/
define bond_create
{
+ option deprecated;
u32 client_index;
u32 context;
u32 id [default=0xFFFFFFFF];
@@ -77,6 +78,42 @@ define bond_create_reply
vl_api_interface_index_t sw_if_index;
};
+/** \brief Initialize a new bond interface with the given paramters
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param mode - mode, required (1=round-robin, 2=active-backup, 3=xor, 4=broadcast, 5=lacp)
+ @param lb - load balance, optional (0=l2, 1=l34, 2=l23) valid for xor and lacp modes. Otherwise ignored (default=l2)
+ @param numa_only - if numa_only is set, pkts will be transmitted by LAG members on local numa node only if have at least one, otherwise it works as usual.
+ @param enable_gso - enable gso support (default 0)
+ @param use_custom_mac - if set, mac_address is valid
+ @param mac_address - mac addr to assign to the interface if use_custom_mac is set
+ @param id - if non-~0, specifies a custom interface ID (default=0xFFFFFFFF)
+*/
+define bond_create2
+{
+ u32 client_index;
+ u32 context;
+ vl_api_bond_mode_t mode;
+ vl_api_bond_lb_algo_t lb;
+ bool numa_only;
+ bool enable_gso;
+ bool use_custom_mac;
+ vl_api_mac_address_t mac_address;
+ u32 id [default=0xFFFFFFFF];
+};
+
+/** \brief Reply for bond create2 reply
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+ @param sw_if_index - software index allocated for the new tap interface
+*/
+define bond_create2_reply
+{
+ u32 context;
+ i32 retval;
+ vl_api_interface_index_t sw_if_index;
+};
+
/** \brief Delete bond interface
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -99,7 +136,7 @@ autoreply define bond_delete
*/
define bond_enslave
{
- option deprecated="20.06";
+ option deprecated;
u32 client_index;
u32 context;
vl_api_interface_index_t sw_if_index;
@@ -153,7 +190,7 @@ define bond_add_member_reply
*/
autoreply define bond_detach_slave
{
- option deprecated="20.06";
+ option deprecated;
u32 client_index;
u32 context;
vl_api_interface_index_t sw_if_index;
@@ -174,7 +211,7 @@ autoreply define bond_detach_member
/** \brief Dump bond interfaces request */
define sw_interface_bond_dump
{
- option deprecated="20.06";
+ option deprecated;
u32 client_index;
u32 context;
};
@@ -240,7 +277,7 @@ define sw_bond_interface_details
*/
define sw_interface_slave_dump
{
- option deprecated="20.06";
+ option deprecated;
u32 client_index;
u32 context;
vl_api_interface_index_t sw_if_index;
diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c
index 4306e3cba9f..8b8385d8205 100644
--- a/src/vnet/bonding/bond_api.c
+++ b/src/vnet/bonding/bond_api.c
@@ -46,6 +46,7 @@
#define foreach_bond_api_msg \
_(BOND_CREATE, bond_create) \
+_(BOND_CREATE2, bond_create2) \
_(BOND_DELETE, bond_delete) \
_(BOND_ENSLAVE, bond_enslave) \
_(BOND_ADD_MEMBER, bond_add_member) \
@@ -103,6 +104,39 @@ vl_api_bond_create_t_handler (vl_api_bond_create_t * mp)
}
static void
+vl_api_bond_create2_t_handler (vl_api_bond_create2_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ vl_api_bond_create2_reply_t *rmp;
+ bond_create_if_args_t _a, *ap = &_a;
+
+ clib_memset (ap, 0, sizeof (*ap));
+
+ ap->id = ntohl (mp->id);
+
+ if (mp->use_custom_mac)
+ {
+ mac_address_decode (mp->mac_address, (mac_address_t *) ap->hw_addr);
+ ap->hw_addr_set = 1;
+ }
+
+ ap->mode = ntohl (mp->mode);
+ ap->lb = ntohl (mp->lb);
+ ap->numa_only = mp->numa_only;
+ ap->gso = mp->enable_gso;
+ bond_create_if (vm, ap);
+
+ int rv = ap->rv;
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_BOND_CREATE2_REPLY,
+ ({
+ rmp->sw_if_index = ntohl (ap->sw_if_index);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
vl_api_bond_add_member_t_handler (vl_api_bond_add_member_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 79e5da499f2..8c5e0e52e54 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -717,6 +717,31 @@ static void *vl_api_bond_create_t_print
FINISH;
}
+static void *vl_api_bond_create2_t_print
+ (vl_api_bond_create2_t * mp, void *handle)
+{
+ u8 *s;
+ u8 null_mac[6];
+
+ clib_memset (null_mac, 0, sizeof (null_mac));
+
+ s = format (0, "SCRIPT: bond_create2 ");
+ if (memcmp (mp->mac_address, null_mac, 6))
+ s = format (s, "mac-address %U ",
+ format_ethernet_address, mp->mac_address);
+ if (mp->mode)
+ s = format (s, "mode %U ", format_bond_mode, ntohl (mp->mode));
+ if (mp->lb)
+ s = format (s, "lb %U ", format_bond_load_balance, ntohl (mp->lb));
+ if (mp->numa_only)
+ s = format (s, "numa-only ");
+ if (mp->enable_gso)
+ s = format (s, "gso ");
+ if (mp->id != ~0)
+ s = format (s, "id %u ", (mp->id));
+ FINISH;
+}
+
static void *vl_api_bond_delete_t_print
(vl_api_bond_delete_t * mp, void *handle)
{
@@ -3592,6 +3617,7 @@ _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
_(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \
_(SW_INTERFACE_SET_GENEVE_BYPASS, sw_interface_set_geneve_bypass) \
_(BOND_CREATE, bond_create) \
+_(BOND_CREATE2, bond_create2) \
_(BOND_DELETE, bond_delete) \
_(BOND_ADD_MEMBER, bond_add_member) \
_(BOND_DETACH_MEMBER, bond_detach_member) \