MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sfc_mac_addr_set

Function sfc_mac_addr_set

dpdk/drivers/net/sfc/sfc_ethdev.c:1176–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1174 return -rc;
1175}
1176static int
1177sfc_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
1178{
1179 struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
1180 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
1181 struct sfc_port *port = &sa->port;
1182 struct rte_ether_addr *old_addr = &dev->data->mac_addrs[0];
1183 int rc = 0;
1184
1185 sfc_adapter_lock(sa);
1186
1187 if (rte_is_same_ether_addr(mac_addr, &port->default_mac_addr))
1188 goto unlock;
1189
1190 /*
1191 * Copy the address to the device private data so that
1192 * it could be recalled in the case of adapter restart.
1193 */
1194 rte_ether_addr_copy(mac_addr, &port->default_mac_addr);
1195
1196 /*
1197 * Neither of the two following checks can return
1198 * an error. The new MAC address is preserved in
1199 * the device private data and can be activated
1200 * on the next port start if the user prevents
1201 * isolated mode from being enabled.
1202 */
1203 if (sfc_sa2shared(sa)->isolated) {
1204 sfc_warn(sa, "isolated mode is active on the port");
1205 sfc_warn(sa, "will not set MAC address");
1206 goto unlock;
1207 }
1208
1209 if (sa->state != SFC_ETHDEV_STARTED) {
1210 sfc_notice(sa, "the port is not started");
1211 sfc_notice(sa, "the new MAC address will be set on port start");
1212
1213 goto unlock;
1214 }
1215
1216 if (encp->enc_allow_set_mac_with_installed_filters) {
1217 rc = efx_mac_addr_set(sa->nic, mac_addr->addr_bytes);
1218 if (rc != 0) {
1219 sfc_err(sa, "cannot set MAC address (rc = %u)", rc);
1220 goto unlock;
1221 }
1222
1223 /*
1224 * Changing the MAC address by means of MCDI request
1225 * has no effect on received traffic, therefore
1226 * we also need to update unicast filters
1227 */
1228 rc = sfc_set_rx_mode_unchecked(sa);
1229 if (rc != 0) {
1230 sfc_err(sa, "cannot set filter (rc = %u)", rc);
1231 /* Rollback the old address */
1232 (void)efx_mac_addr_set(sa->nic, old_addr->addr_bytes);
1233 (void)sfc_set_rx_mode_unchecked(sa);

Callers

nothing calls this directly

Calls 9

sfc_adapter_by_eth_devFunction · 0.85
efx_nic_cfg_getFunction · 0.85
rte_is_same_ether_addrFunction · 0.85
rte_ether_addr_copyFunction · 0.85
sfc_sa2sharedFunction · 0.85
efx_mac_addr_setFunction · 0.85
sfc_stopFunction · 0.85
sfc_startFunction · 0.85

Tested by

no test coverage detected