FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
gso.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vlib/vlib.h>
17 #include <vnet/vnet.h>
18 #include <vppinfra/error.h>
19 #include <vnet/feature/feature.h>
21 #include <vnet/gso/gso.h>
22 
24 
25 int
27 {
30  ethernet_main_t *em;
31  vnet_main_t *vnm;
32 
33  vnm = vnet_get_main ();
34  em = &ethernet_main;
35  si = vnet_get_sw_interface (vnm, sw_if_index);
36 
38  {
39  si = vnet_get_sup_sw_interface (vnm, sw_if_index);
40  }
41 
43  {
44  return (VNET_API_ERROR_INVALID_VALUE);
45  }
46 
47  eif = ethernet_get_interface (em, si->hw_if_index);
48 
49  if (!eif)
50  {
51  return (VNET_API_ERROR_FEATURE_DISABLED);
52  }
53 
54  vnet_feature_enable_disable ("ip4-output", "gso-ip4", sw_if_index, enable,
55  0, 0);
56  vnet_feature_enable_disable ("ip6-output", "gso-ip6", sw_if_index, enable,
57  0, 0);
58 
59  vnet_l2_feature_enable_disable ("l2-output-nonip", "gso-l2-nonip",
60  sw_if_index, enable, 0, 0);
61  vnet_l2_feature_enable_disable ("l2-output-ip4", "gso-l2-ip4",
62  sw_if_index, enable, 0, 0);
63  vnet_l2_feature_enable_disable ("l2-output-ip6", "gso-l2-ip6",
64  sw_if_index, enable, 0, 0);
65 
66  return (0);
67 }
68 
69 static clib_error_t *
71 {
73 
74  clib_memset (gm, 0, sizeof (gm[0]));
75  gm->vlib_main = vm;
76  gm->vnet_main = vnet_get_main ();
77 
78  return 0;
79 }
80 
82 
83 /*
84  * fd.io coding-style-patch-verification: ON
85  *
86  * Local Variables:
87  * eval: (c-set-style "gnu")
88  * End:
89  */
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
int vnet_sw_interface_gso_enable_disable(u32 sw_if_index, u8 enable)
Definition: gso.c:26
gso_main_t gso_main
Definition: gso.c:23
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
vlib_main_t * vlib_main
Definition: gso.h:38
unsigned char u8
Definition: types.h:56
ethernet_main_t ethernet_main
Definition: init.c:45
vl_api_interface_index_t sw_if_index
Definition: gre.api:59
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * gso_init(vlib_main_t *vm)
Definition: gso.c:70
unsigned int u32
Definition: types.h:88
#define gm
Definition: dlmalloc.c:1219
vlib_main_t * vm
Definition: in2out_ed.c:1810
int vnet_l2_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
vnet_main_t * vnet_main
Definition: gso.h:39
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:940
vnet_sw_interface_type_t type
Definition: interface.h:718
Definition: gso.h:36
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:304