Line data Source code
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/ethernet/ethernet.h> 20 : #include <vnet/feature/feature.h> 21 : #include <vnet/gso/gso.h> 22 : 23 : static clib_error_t * 24 0 : set_interface_feature_gso_command_fn (vlib_main_t * vm, 25 : unformat_input_t * input, 26 : vlib_cli_command_t * cmd) 27 : { 28 0 : vnet_main_t *vnm = vnet_get_main (); 29 0 : unformat_input_t _line_input, *line_input = &_line_input; 30 0 : clib_error_t *error = 0; 31 : 32 0 : u32 sw_if_index = ~0; 33 0 : u8 enable = 0; 34 : 35 : /* Get a line of input. */ 36 0 : if (!unformat_user (input, unformat_line_input, line_input)) 37 0 : return 0; 38 : 39 0 : while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) 40 : { 41 0 : if (unformat 42 : (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) 43 : ; 44 0 : else if (unformat (line_input, "enable")) 45 0 : enable = 1; 46 0 : else if (unformat (line_input, "disable")) 47 0 : enable = 0; 48 : else 49 : { 50 0 : error = unformat_parse_error (line_input); 51 0 : goto done; 52 : } 53 : } 54 : 55 0 : if (sw_if_index == ~0) 56 : { 57 0 : error = clib_error_return (0, "Interface not specified..."); 58 0 : goto done; 59 : } 60 0 : int rv = vnet_sw_interface_gso_enable_disable (sw_if_index, enable); 61 : 62 0 : switch (rv) 63 : { 64 0 : case VNET_API_ERROR_INVALID_VALUE: 65 0 : error = clib_error_return (0, "interface type is not hardware"); 66 0 : break; 67 0 : case VNET_API_ERROR_FEATURE_DISABLED: 68 0 : error = clib_error_return (0, "interface should be ethernet interface"); 69 0 : break; 70 : default: 71 : ; 72 : } 73 : 74 0 : done: 75 0 : unformat_free (line_input); 76 0 : return error; 77 : } 78 : 79 : /* *INDENT-OFF* */ 80 285289 : VLIB_CLI_COMMAND (set_interface_feature_gso_command, static) = { 81 : .path = "set interface feature gso", 82 : .short_help = "set interface feature gso <intfc> [enable | disable]", 83 : .function = set_interface_feature_gso_command_fn, 84 : }; 85 : /* *INDENT-ON* */ 86 : 87 : /* 88 : * fd.io coding-style-patch-verification: ON 89 : * 90 : * Local Variables: 91 : * eval: (c-set-style "gnu") 92 : * End: 93 : */