gso: Add gso feature arc
Type: refactor Change-Id: Ib4a8e7e64093b2db1deda6663325080bc8337605 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
This commit is contained in:
committed by
Andrew Yourtchenko
parent
26c7a4b0b6
commit
29467b5347
@@ -194,6 +194,7 @@ F: src/vnet/lisp-gpe/
|
||||
VNET GSO
|
||||
I: gso
|
||||
M: Andrew Yourtchenko <ayourtch@gmail.com>
|
||||
M: Mohsin Kazmi <sykazmi@cisco.com>
|
||||
F: src/vnet/interface_output.c
|
||||
|
||||
Plugin - MAP
|
||||
|
||||
@@ -5174,6 +5174,7 @@ _(delete_subif_reply) \
|
||||
_(l2_interface_pbb_tag_rewrite_reply) \
|
||||
_(set_punt_reply) \
|
||||
_(feature_enable_disable_reply) \
|
||||
_(feature_gso_enable_disable_reply) \
|
||||
_(sw_interface_tag_add_del_reply) \
|
||||
_(sw_interface_add_del_mac_address_reply) \
|
||||
_(hw_interface_set_mtu_reply) \
|
||||
@@ -5483,6 +5484,7 @@ _(SET_PUNT_REPLY, set_punt_reply) \
|
||||
_(IP_TABLE_DETAILS, ip_table_details) \
|
||||
_(IP_ROUTE_DETAILS, ip_route_details) \
|
||||
_(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
|
||||
_(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
|
||||
_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
|
||||
_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
|
||||
_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
|
||||
@@ -19965,6 +19967,45 @@ api_feature_enable_disable (vat_main_t * vam)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
api_feature_gso_enable_disable (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t *i = vam->input;
|
||||
vl_api_feature_gso_enable_disable_t *mp;
|
||||
u32 sw_if_index = ~0;
|
||||
u8 enable = 1;
|
||||
int ret;
|
||||
|
||||
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
|
||||
;
|
||||
else if (unformat (i, "sw_if_index %d", &sw_if_index))
|
||||
;
|
||||
else if (unformat (i, "enable"))
|
||||
enable = 1;
|
||||
else if (unformat (i, "disable"))
|
||||
enable = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (sw_if_index == ~0)
|
||||
{
|
||||
errmsg ("missing interface name or sw_if_index");
|
||||
return -99;
|
||||
}
|
||||
|
||||
/* Construct the API message */
|
||||
M (FEATURE_GSO_ENABLE_DISABLE, mp);
|
||||
mp->sw_if_index = ntohl (sw_if_index);
|
||||
mp->enable_disable = enable;
|
||||
|
||||
S (mp);
|
||||
W (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
api_sw_interface_tag_add_del (vat_main_t * vam)
|
||||
{
|
||||
@@ -21814,6 +21855,8 @@ _(ip_mtable_dump, "") \
|
||||
_(ip_mroute_dump, "table-id [ip4|ip6]") \
|
||||
_(feature_enable_disable, "arc_name <arc_name> " \
|
||||
"feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
|
||||
_(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
|
||||
"[enable | disable] ") \
|
||||
_(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
|
||||
"[disable]") \
|
||||
_(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
|
||||
|
||||
@@ -940,6 +940,24 @@ list(APPEND VNET_HEADERS
|
||||
|
||||
list(APPEND VNET_API_FILES ipfix-export/ipfix_export.api)
|
||||
|
||||
##############################################################################
|
||||
# GSO
|
||||
##############################################################################
|
||||
list(APPEND VNET_SOURCES
|
||||
gso/cli.c
|
||||
gso/gso.c
|
||||
gso/gso_api.c
|
||||
gso/node.c
|
||||
)
|
||||
|
||||
list(APPEND VNET_HEADERS
|
||||
gso/gso.h
|
||||
)
|
||||
|
||||
list(APPEND VNET_API_FILES
|
||||
gso/gso.api
|
||||
)
|
||||
|
||||
##############################################################################
|
||||
# IPFIX classify code
|
||||
##############################################################################
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
||||
#include <vppinfra/error.h>
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/feature/feature.h>
|
||||
#include <vnet/gso/gso.h>
|
||||
|
||||
static clib_error_t *
|
||||
set_interface_feature_gso_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t * input,
|
||||
vlib_cli_command_t * cmd)
|
||||
{
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
clib_error_t *error = 0;
|
||||
|
||||
u32 sw_if_index = ~0;
|
||||
u8 enable = 0;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat
|
||||
(line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
|
||||
;
|
||||
else if (unformat (line_input, "enable"))
|
||||
enable = 1;
|
||||
else if (unformat (line_input, "disable"))
|
||||
enable = 0;
|
||||
else
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (sw_if_index == ~0)
|
||||
{
|
||||
error = clib_error_return (0, "Interface not specified...");
|
||||
goto done;
|
||||
}
|
||||
int rv = vnet_sw_interface_gso_enable_disable (sw_if_index, enable);
|
||||
|
||||
switch (rv)
|
||||
{
|
||||
case VNET_API_ERROR_INVALID_VALUE:
|
||||
error = clib_error_return (0, "interface type is not hardware");
|
||||
break;
|
||||
case VNET_API_ERROR_FEATURE_DISABLED:
|
||||
error = clib_error_return (0, "interface should be ethernet interface");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
VLIB_CLI_COMMAND (set_interface_feature_gso_command, static) = {
|
||||
.path = "set interface feature gso",
|
||||
.short_help = "set interface feature gso <intfc> [enable | disable]",
|
||||
.function = set_interface_feature_gso_command_fn,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
option version = "1.0.0";
|
||||
|
||||
import "vnet/interface_types.api";
|
||||
|
||||
/** \brief Enable or disable interface feature gso arc
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param sw_if_index - The interface to enable/disable gso feature arc.
|
||||
@param enable_disable - set to 1 to enable, 0 to disable gso feature arc
|
||||
*/
|
||||
autoreply define feature_gso_enable_disable
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
bool enable_disable;
|
||||
option vat_help = "<intfc> | sw_if_index <nn> [enable | disable]";
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
||||
#include <vppinfra/error.h>
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/feature/feature.h>
|
||||
#include <vnet/l2/l2_in_out_feat_arc.h>
|
||||
#include <vnet/gso/gso.h>
|
||||
|
||||
gso_main_t gso_main;
|
||||
|
||||
int
|
||||
vnet_sw_interface_gso_enable_disable (u32 sw_if_index, u8 enable)
|
||||
{
|
||||
ethernet_interface_t *eif;
|
||||
vnet_sw_interface_t *si;
|
||||
ethernet_main_t *em;
|
||||
vnet_main_t *vnm;
|
||||
|
||||
vnm = vnet_get_main ();
|
||||
em = ðernet_main;
|
||||
si = vnet_get_sw_interface (vnm, sw_if_index);
|
||||
|
||||
/*
|
||||
* only ethernet HW interfaces are supported at this time
|
||||
*/
|
||||
if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
|
||||
{
|
||||
return (VNET_API_ERROR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
eif = ethernet_get_interface (em, si->hw_if_index);
|
||||
|
||||
if (!eif)
|
||||
{
|
||||
return (VNET_API_ERROR_FEATURE_DISABLED);
|
||||
}
|
||||
|
||||
vnet_feature_enable_disable ("ip4-output", "gso-ip4", sw_if_index, enable,
|
||||
0, 0);
|
||||
vnet_feature_enable_disable ("ip6-output", "gso-ip6", sw_if_index, enable,
|
||||
0, 0);
|
||||
|
||||
vnet_l2_feature_enable_disable ("l2-output-nonip", "gso-l2-nonip",
|
||||
sw_if_index, enable, 0, 0);
|
||||
vnet_l2_feature_enable_disable ("l2-output-ip4", "gso-l2-ip4",
|
||||
sw_if_index, enable, 0, 0);
|
||||
vnet_l2_feature_enable_disable ("l2-output-ip6", "gso-l2-ip6",
|
||||
sw_if_index, enable, 0, 0);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
gso_init (vlib_main_t * vm)
|
||||
{
|
||||
gso_main_t *gm = &gso_main;
|
||||
|
||||
clib_memset (gm, 0, sizeof (gm[0]));
|
||||
gm->vlib_main = vm;
|
||||
gm->vnet_main = vnet_get_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VLIB_INIT_FUNCTION (gso_init);
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef included_gso_h
|
||||
#define included_gso_h
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
u16 msg_id_base;
|
||||
} gso_main_t;
|
||||
|
||||
extern gso_main_t gso_main;
|
||||
|
||||
int vnet_sw_interface_gso_enable_disable (u32 sw_if_index, u8 enable);
|
||||
|
||||
#endif /* included_gso_h */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* gso_api.c - Generic Segmentation Offload api
|
||||
*
|
||||
* Copyright (c) 2019 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
#include <vlibmemory/api.h>
|
||||
#include <vnet/gso/gso.h>
|
||||
|
||||
#include <vnet/vnet_msg_enum.h>
|
||||
|
||||
#define vl_typedefs /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_typedefs
|
||||
|
||||
#define vl_endianfun /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_endianfun
|
||||
|
||||
/* instantiate all the print functions we know about */
|
||||
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
|
||||
#define vl_printfun
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_printfun
|
||||
|
||||
#include <vlibapi/api_helper_macros.h>
|
||||
|
||||
#define foreach_feature_gso_api_msg \
|
||||
_(FEATURE_GSO_ENABLE_DISABLE, feature_gso_enable_disable)
|
||||
|
||||
static void
|
||||
vl_api_feature_gso_enable_disable_t_handler
|
||||
(vl_api_feature_gso_enable_disable_t * mp)
|
||||
{
|
||||
vl_api_feature_gso_enable_disable_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
VALIDATE_SW_IF_INDEX (mp);
|
||||
|
||||
rv =
|
||||
vnet_sw_interface_gso_enable_disable (ntohl (mp->sw_if_index),
|
||||
mp->enable_disable);
|
||||
|
||||
BAD_SW_IF_INDEX_LABEL;
|
||||
|
||||
REPLY_MACRO (VL_API_FEATURE_GSO_ENABLE_DISABLE_REPLY);
|
||||
}
|
||||
|
||||
#define vl_msg_name_crc_list
|
||||
#include <vnet/gso/gso.api.h>
|
||||
#undef vl_msg_name_crc_list
|
||||
|
||||
static void
|
||||
setup_message_id_table (api_main_t * am)
|
||||
{
|
||||
#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
|
||||
foreach_vl_msg_name_crc_gso;
|
||||
#undef _
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
feature_gso_api_hookup (vlib_main_t * vm)
|
||||
{
|
||||
api_main_t *am = &api_main;
|
||||
|
||||
#define _(N,n) \
|
||||
vl_msg_api_set_handlers(VL_API_##N, #n, \
|
||||
vl_api_##n##_t_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_api_##n##_t_endian, \
|
||||
vl_api_##n##_t_print, \
|
||||
sizeof(vl_api_##n##_t), 1);
|
||||
foreach_feature_gso_api_msg;
|
||||
#undef _
|
||||
|
||||
/*
|
||||
* Set up the (msg_name, crc, message-id) table
|
||||
*/
|
||||
setup_message_id_table (am);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VLIB_API_INIT_FUNCTION (feature_gso_api_hookup);
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
+14
-377
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,7 @@
|
||||
#include <vnet/vxlan-gbp/vxlan_gbp.api.h>
|
||||
#include <vnet/syslog/syslog.api.h>
|
||||
#include <vnet/devices/virtio/virtio.api.h>
|
||||
#include <vnet/gso/gso.api.h>
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
|
||||
@@ -3475,6 +3475,21 @@ static void *vl_api_feature_enable_disable_t_print
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_feature_gso_enable_disable_t_print
|
||||
(vl_api_feature_gso_enable_disable_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: feature_gso_enable_disable ");
|
||||
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
|
||||
if (mp->enable_disable)
|
||||
s = format (s, "enable");
|
||||
if (!mp->enable_disable)
|
||||
s = format (s, "disable");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_sw_interface_tag_add_del_t_print
|
||||
(vl_api_sw_interface_tag_add_del_t * mp, void *handle)
|
||||
{
|
||||
@@ -3866,6 +3881,7 @@ _(IOAM_DISABLE, ioam_disable) \
|
||||
_(IP_TABLE_DUMP, ip_table_dump) \
|
||||
_(IP_ROUTE_DUMP, ip_route_dump) \
|
||||
_(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
|
||||
_(FEATURE_GSO_ENABLE_DISABLE, feature_gso_enable_disable) \
|
||||
_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \
|
||||
_(HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \
|
||||
_(P2P_ETHERNET_ADD, p2p_ethernet_add) \
|
||||
|
||||
@@ -129,6 +129,7 @@ class TestGSO(VppTestCase):
|
||||
i.resolve_arp()
|
||||
i.resolve_ndp()
|
||||
|
||||
self.vapi.feature_gso_enable_disable(self.pg4.sw_if_index)
|
||||
p42 = (Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) /
|
||||
IP(src=self.pg2.remote_ip4, dst=self.pg4.remote_ip4,
|
||||
flags='DF') /
|
||||
@@ -186,6 +187,7 @@ class TestGSO(VppTestCase):
|
||||
i.resolve_ndp()
|
||||
|
||||
self.vapi.sw_interface_set_mtu(self.pg5.sw_if_index, [9000, 0, 0, 0])
|
||||
self.vapi.feature_gso_enable_disable(self.pg1.sw_if_index)
|
||||
p44 = (Ether(src=self.pg5.remote_mac, dst=self.pg5.local_mac) /
|
||||
IP(src=self.pg5.remote_ip4, dst=self.pg1.remote_ip4) /
|
||||
TCP(sport=1234, dport=1234) /
|
||||
|
||||
@@ -2050,3 +2050,10 @@ class VppPapiProvider(object):
|
||||
'sw_if_index': sw_if_index,
|
||||
'is_enable': is_enable,
|
||||
})
|
||||
|
||||
def feature_gso_enable_disable(self, sw_if_index, enable_disable=1):
|
||||
return self.api(self.papi.feature_gso_enable_disable,
|
||||
{
|
||||
'sw_if_index': sw_if_index,
|
||||
'enable_disable': enable_disable,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user