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