| 1110 | } |
| 1111 | |
| 1112 | static int |
| 1113 | sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) |
| 1114 | { |
| 1115 | struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); |
| 1116 | size_t pdu = EFX_MAC_PDU(mtu); |
| 1117 | size_t old_pdu; |
| 1118 | int rc; |
| 1119 | |
| 1120 | sfc_log_init(sa, "mtu=%u", mtu); |
| 1121 | |
| 1122 | rc = EINVAL; |
| 1123 | if (pdu < EFX_MAC_PDU_MIN) { |
| 1124 | sfc_err(sa, "too small MTU %u (PDU size %u less than min %u)", |
| 1125 | (unsigned int)mtu, (unsigned int)pdu, |
| 1126 | EFX_MAC_PDU_MIN); |
| 1127 | goto fail_inval; |
| 1128 | } |
| 1129 | if (pdu > EFX_MAC_PDU_MAX) { |
| 1130 | sfc_err(sa, "too big MTU %u (PDU size %u greater than max %u)", |
| 1131 | (unsigned int)mtu, (unsigned int)pdu, |
| 1132 | (unsigned int)EFX_MAC_PDU_MAX); |
| 1133 | goto fail_inval; |
| 1134 | } |
| 1135 | |
| 1136 | sfc_adapter_lock(sa); |
| 1137 | |
| 1138 | rc = sfc_check_scatter_on_all_rx_queues(sa, pdu); |
| 1139 | if (rc != 0) |
| 1140 | goto fail_check_scatter; |
| 1141 | |
| 1142 | if (pdu != sa->port.pdu) { |
| 1143 | if (sa->state == SFC_ETHDEV_STARTED) { |
| 1144 | sfc_stop(sa); |
| 1145 | |
| 1146 | old_pdu = sa->port.pdu; |
| 1147 | sa->port.pdu = pdu; |
| 1148 | rc = sfc_start(sa); |
| 1149 | if (rc != 0) |
| 1150 | goto fail_start; |
| 1151 | } else { |
| 1152 | sa->port.pdu = pdu; |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | sfc_adapter_unlock(sa); |
| 1157 | |
| 1158 | sfc_log_init(sa, "done"); |
| 1159 | return 0; |
| 1160 | |
| 1161 | fail_start: |
| 1162 | sa->port.pdu = old_pdu; |
| 1163 | if (sfc_start(sa) != 0) |
| 1164 | sfc_err(sa, "cannot start with neither new (%u) nor old (%u) " |
| 1165 | "PDU max size - port is stopped", |
| 1166 | (unsigned int)pdu, (unsigned int)old_pdu); |
| 1167 | |
| 1168 | fail_check_scatter: |
| 1169 | sfc_adapter_unlock(sa); |
nothing calls this directly
no test coverage detected