| 4067 | } |
| 4068 | |
| 4069 | int |
| 4070 | rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) |
| 4071 | { |
| 4072 | int ret; |
| 4073 | struct rte_eth_dev_info dev_info; |
| 4074 | struct rte_eth_dev *dev; |
| 4075 | |
| 4076 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); |
| 4077 | dev = &rte_eth_devices[port_id]; |
| 4078 | if (*dev->dev_ops->mtu_set == NULL) |
| 4079 | return -ENOTSUP; |
| 4080 | |
| 4081 | /* |
| 4082 | * Check if the device supports dev_infos_get, if it does not |
| 4083 | * skip min_mtu/max_mtu validation here as this requires values |
| 4084 | * that are populated within the call to rte_eth_dev_info_get() |
| 4085 | * which relies on dev->dev_ops->dev_infos_get. |
| 4086 | */ |
| 4087 | if (*dev->dev_ops->dev_infos_get != NULL) { |
| 4088 | ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 4089 | if (ret != 0) |
| 4090 | return ret; |
| 4091 | |
| 4092 | ret = eth_dev_validate_mtu(port_id, &dev_info, mtu); |
| 4093 | if (ret != 0) |
| 4094 | return ret; |
| 4095 | } |
| 4096 | |
| 4097 | if (dev->data->dev_configured == 0) { |
| 4098 | RTE_ETHDEV_LOG(ERR, |
| 4099 | "Port %u must be configured before MTU set\n", |
| 4100 | port_id); |
| 4101 | return -EINVAL; |
| 4102 | } |
| 4103 | |
| 4104 | ret = (*dev->dev_ops->mtu_set)(dev, mtu); |
| 4105 | if (ret == 0) |
| 4106 | dev->data->mtu = mtu; |
| 4107 | |
| 4108 | ret = eth_err(port_id, ret); |
| 4109 | |
| 4110 | rte_ethdev_trace_set_mtu(port_id, mtu, ret); |
| 4111 | |
| 4112 | return ret; |
| 4113 | } |
| 4114 | |
| 4115 | int |
| 4116 | rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on) |