blob: cf90d22696d1a32b033564464dd88e31fc91a34c [file] [log] [blame]
Mohsin Kazmi29467b52019-10-08 19:42:38 +02001/*
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>
Mohsin Kazmi29467b52019-10-08 19:42:38 +020019#include <vnet/feature/feature.h>
20#include <vnet/l2/l2_in_out_feat_arc.h>
21#include <vnet/gso/gso.h>
22
23gso_main_t gso_main;
24
25int
26vnet_sw_interface_gso_enable_disable (u32 sw_if_index, u8 enable)
27{
28 ethernet_interface_t *eif;
29 vnet_sw_interface_t *si;
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
37 /*
38 * only ethernet HW interfaces are supported at this time
39 */
40 if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
41 {
42 return (VNET_API_ERROR_INVALID_VALUE);
43 }
44
45 eif = ethernet_get_interface (em, si->hw_if_index);
46
47 if (!eif)
48 {
49 return (VNET_API_ERROR_FEATURE_DISABLED);
50 }
51
52 vnet_feature_enable_disable ("ip4-output", "gso-ip4", sw_if_index, enable,
53 0, 0);
54 vnet_feature_enable_disable ("ip6-output", "gso-ip6", sw_if_index, enable,
55 0, 0);
56
57 vnet_l2_feature_enable_disable ("l2-output-nonip", "gso-l2-nonip",
58 sw_if_index, enable, 0, 0);
59 vnet_l2_feature_enable_disable ("l2-output-ip4", "gso-l2-ip4",
60 sw_if_index, enable, 0, 0);
61 vnet_l2_feature_enable_disable ("l2-output-ip6", "gso-l2-ip6",
62 sw_if_index, enable, 0, 0);
63
64 return (0);
65}
66
67static clib_error_t *
68gso_init (vlib_main_t * vm)
69{
70 gso_main_t *gm = &gso_main;
71
72 clib_memset (gm, 0, sizeof (gm[0]));
73 gm->vlib_main = vm;
74 gm->vnet_main = vnet_get_main ();
75
76 return 0;
77}
78
79VLIB_INIT_FUNCTION (gso_init);
80
81/*
82 * fd.io coding-style-patch-verification: ON
83 *
84 * Local Variables:
85 * eval: (c-set-style "gnu")
86 * End:
87 */