1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */
4 #include <linux/etherdevice.h>
5 #include <linux/ipv6.h>
6 #include <linux/types.h>
7 #include <net/netdev_queues.h>
10 #include "fbnic_netdev.h"
11 #include "fbnic_txrx.h"
13 int __fbnic_open(struct fbnic_net
*fbn
)
15 struct fbnic_dev
*fbd
= fbn
->fbd
;
18 err
= fbnic_alloc_napi_vectors(fbn
);
22 err
= fbnic_alloc_resources(fbn
);
24 goto free_napi_vectors
;
26 err
= netif_set_real_num_tx_queues(fbn
->netdev
,
31 err
= netif_set_real_num_rx_queues(fbn
->netdev
,
36 /* Send ownership message and flush to verify FW has seen it */
37 err
= fbnic_fw_xmit_ownership_msg(fbd
, true);
40 "Error %d sending host ownership message to the firmware\n",
45 err
= fbnic_time_start(fbn
);
47 goto release_ownership
;
49 err
= fbnic_fw_init_heartbeat(fbd
, false);
53 err
= fbnic_pcs_irq_enable(fbd
);
56 /* Pull the BMC config and initialize the RPC */
57 fbnic_bmc_rpc_init(fbd
);
58 fbnic_rss_reinit(fbd
, fbn
);
64 fbnic_fw_xmit_ownership_msg(fbn
->fbd
, false);
66 fbnic_free_resources(fbn
);
68 fbnic_free_napi_vectors(fbn
);
72 static int fbnic_open(struct net_device
*netdev
)
74 struct fbnic_net
*fbn
= netdev_priv(netdev
);
77 err
= __fbnic_open(fbn
);
84 static int fbnic_stop(struct net_device
*netdev
)
86 struct fbnic_net
*fbn
= netdev_priv(netdev
);
89 fbnic_pcs_irq_disable(fbn
->fbd
);
92 fbnic_fw_xmit_ownership_msg(fbn
->fbd
, false);
94 fbnic_free_resources(fbn
);
95 fbnic_free_napi_vectors(fbn
);
100 static int fbnic_uc_sync(struct net_device
*netdev
, const unsigned char *addr
)
102 struct fbnic_net
*fbn
= netdev_priv(netdev
);
103 struct fbnic_mac_addr
*avail_addr
;
105 if (WARN_ON(!is_valid_ether_addr(addr
)))
106 return -EADDRNOTAVAIL
;
108 avail_addr
= __fbnic_uc_sync(fbn
->fbd
, addr
);
112 /* Add type flag indicating this address is in use by the host */
113 set_bit(FBNIC_MAC_ADDR_T_UNICAST
, avail_addr
->act_tcam
);
118 static int fbnic_uc_unsync(struct net_device
*netdev
, const unsigned char *addr
)
120 struct fbnic_net
*fbn
= netdev_priv(netdev
);
121 struct fbnic_dev
*fbd
= fbn
->fbd
;
124 /* Scan from middle of list to bottom, filling bottom up.
125 * Skip the first entry which is reserved for dev_addr and
126 * leave the last entry to use for promiscuous filtering.
128 for (i
= fbd
->mac_addr_boundary
, ret
= -ENOENT
;
129 i
< FBNIC_RPC_TCAM_MACDA_HOST_ADDR_IDX
&& ret
; i
++) {
130 struct fbnic_mac_addr
*mac_addr
= &fbd
->mac_addr
[i
];
132 if (!ether_addr_equal(mac_addr
->value
.addr8
, addr
))
135 ret
= __fbnic_uc_unsync(mac_addr
);
141 static int fbnic_mc_sync(struct net_device
*netdev
, const unsigned char *addr
)
143 struct fbnic_net
*fbn
= netdev_priv(netdev
);
144 struct fbnic_mac_addr
*avail_addr
;
146 if (WARN_ON(!is_multicast_ether_addr(addr
)))
147 return -EADDRNOTAVAIL
;
149 avail_addr
= __fbnic_mc_sync(fbn
->fbd
, addr
);
153 /* Add type flag indicating this address is in use by the host */
154 set_bit(FBNIC_MAC_ADDR_T_MULTICAST
, avail_addr
->act_tcam
);
159 static int fbnic_mc_unsync(struct net_device
*netdev
, const unsigned char *addr
)
161 struct fbnic_net
*fbn
= netdev_priv(netdev
);
162 struct fbnic_dev
*fbd
= fbn
->fbd
;
165 /* Scan from middle of list to top, filling top down.
166 * Skip over the address reserved for the BMC MAC and
167 * exclude index 0 as that belongs to the broadcast address
169 for (i
= fbd
->mac_addr_boundary
, ret
= -ENOENT
;
170 --i
> FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX
&& ret
;) {
171 struct fbnic_mac_addr
*mac_addr
= &fbd
->mac_addr
[i
];
173 if (!ether_addr_equal(mac_addr
->value
.addr8
, addr
))
176 ret
= __fbnic_mc_unsync(mac_addr
);
182 void __fbnic_set_rx_mode(struct net_device
*netdev
)
184 struct fbnic_net
*fbn
= netdev_priv(netdev
);
185 bool uc_promisc
= false, mc_promisc
= false;
186 struct fbnic_dev
*fbd
= fbn
->fbd
;
187 struct fbnic_mac_addr
*mac_addr
;
190 /* Populate host address from dev_addr */
191 mac_addr
= &fbd
->mac_addr
[FBNIC_RPC_TCAM_MACDA_HOST_ADDR_IDX
];
192 if (!ether_addr_equal(mac_addr
->value
.addr8
, netdev
->dev_addr
) ||
193 mac_addr
->state
!= FBNIC_TCAM_S_VALID
) {
194 ether_addr_copy(mac_addr
->value
.addr8
, netdev
->dev_addr
);
195 mac_addr
->state
= FBNIC_TCAM_S_UPDATE
;
196 set_bit(FBNIC_MAC_ADDR_T_UNICAST
, mac_addr
->act_tcam
);
199 /* Populate broadcast address if broadcast is enabled */
200 mac_addr
= &fbd
->mac_addr
[FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX
];
201 if (netdev
->flags
& IFF_BROADCAST
) {
202 if (!is_broadcast_ether_addr(mac_addr
->value
.addr8
) ||
203 mac_addr
->state
!= FBNIC_TCAM_S_VALID
) {
204 eth_broadcast_addr(mac_addr
->value
.addr8
);
205 mac_addr
->state
= FBNIC_TCAM_S_ADD
;
207 set_bit(FBNIC_MAC_ADDR_T_BROADCAST
, mac_addr
->act_tcam
);
208 } else if (mac_addr
->state
== FBNIC_TCAM_S_VALID
) {
209 __fbnic_xc_unsync(mac_addr
, FBNIC_MAC_ADDR_T_BROADCAST
);
212 /* Synchronize unicast and multicast address lists */
213 err
= __dev_uc_sync(netdev
, fbnic_uc_sync
, fbnic_uc_unsync
);
216 err
= __dev_mc_sync(netdev
, fbnic_mc_sync
, fbnic_mc_unsync
);
220 uc_promisc
|= !!(netdev
->flags
& IFF_PROMISC
);
221 mc_promisc
|= !!(netdev
->flags
& IFF_ALLMULTI
) || uc_promisc
;
223 /* Populate last TCAM entry with promiscuous entry and 0/1 bit mask */
224 mac_addr
= &fbd
->mac_addr
[FBNIC_RPC_TCAM_MACDA_PROMISC_IDX
];
226 if (!is_zero_ether_addr(mac_addr
->value
.addr8
) ||
227 mac_addr
->state
!= FBNIC_TCAM_S_VALID
) {
228 eth_zero_addr(mac_addr
->value
.addr8
);
229 eth_broadcast_addr(mac_addr
->mask
.addr8
);
230 clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI
,
232 set_bit(FBNIC_MAC_ADDR_T_PROMISC
,
234 mac_addr
->state
= FBNIC_TCAM_S_ADD
;
236 } else if (mc_promisc
&&
237 (!fbnic_bmc_present(fbd
) || !fbd
->fw_cap
.all_multi
)) {
238 /* We have to add a special handler for multicast as the
239 * BMC may have an all-multi rule already in place. As such
240 * adding a rule ourselves won't do any good so we will have
241 * to modify the rules for the ALL MULTI below if the BMC
242 * already has the rule in place.
244 if (!is_multicast_ether_addr(mac_addr
->value
.addr8
) ||
245 mac_addr
->state
!= FBNIC_TCAM_S_VALID
) {
246 eth_zero_addr(mac_addr
->value
.addr8
);
247 eth_broadcast_addr(mac_addr
->mask
.addr8
);
248 mac_addr
->value
.addr8
[0] ^= 1;
249 mac_addr
->mask
.addr8
[0] ^= 1;
250 set_bit(FBNIC_MAC_ADDR_T_ALLMULTI
,
252 clear_bit(FBNIC_MAC_ADDR_T_PROMISC
,
254 mac_addr
->state
= FBNIC_TCAM_S_ADD
;
256 } else if (mac_addr
->state
== FBNIC_TCAM_S_VALID
) {
257 if (test_bit(FBNIC_MAC_ADDR_T_BMC
, mac_addr
->act_tcam
)) {
258 clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI
,
260 clear_bit(FBNIC_MAC_ADDR_T_PROMISC
,
263 mac_addr
->state
= FBNIC_TCAM_S_DELETE
;
267 /* Add rules for BMC all multicast if it is enabled */
268 fbnic_bmc_rpc_all_multi_config(fbd
, mc_promisc
);
270 /* Sift out any unshared BMC rules and place them in BMC only section */
271 fbnic_sift_macda(fbd
);
273 /* Write updates to hardware */
274 fbnic_write_rules(fbd
);
275 fbnic_write_macda(fbd
);
276 fbnic_write_tce_tcam(fbd
);
279 static void fbnic_set_rx_mode(struct net_device
*netdev
)
281 /* No need to update the hardware if we are not running */
282 if (netif_running(netdev
))
283 __fbnic_set_rx_mode(netdev
);
286 static int fbnic_set_mac(struct net_device
*netdev
, void *p
)
288 struct sockaddr
*addr
= p
;
290 if (!is_valid_ether_addr(addr
->sa_data
))
291 return -EADDRNOTAVAIL
;
293 eth_hw_addr_set(netdev
, addr
->sa_data
);
295 fbnic_set_rx_mode(netdev
);
300 void fbnic_clear_rx_mode(struct net_device
*netdev
)
302 struct fbnic_net
*fbn
= netdev_priv(netdev
);
303 struct fbnic_dev
*fbd
= fbn
->fbd
;
306 for (idx
= ARRAY_SIZE(fbd
->mac_addr
); idx
--;) {
307 struct fbnic_mac_addr
*mac_addr
= &fbd
->mac_addr
[idx
];
309 if (mac_addr
->state
!= FBNIC_TCAM_S_VALID
)
312 bitmap_clear(mac_addr
->act_tcam
,
313 FBNIC_MAC_ADDR_T_HOST_START
,
314 FBNIC_MAC_ADDR_T_HOST_LEN
);
316 if (bitmap_empty(mac_addr
->act_tcam
,
317 FBNIC_RPC_TCAM_ACT_NUM_ENTRIES
))
318 mac_addr
->state
= FBNIC_TCAM_S_DELETE
;
321 /* Write updates to hardware */
322 fbnic_write_macda(fbd
);
324 __dev_uc_unsync(netdev
, NULL
);
325 __dev_mc_unsync(netdev
, NULL
);
328 static int fbnic_hwtstamp_get(struct net_device
*netdev
,
329 struct kernel_hwtstamp_config
*config
)
331 struct fbnic_net
*fbn
= netdev_priv(netdev
);
333 *config
= fbn
->hwtstamp_config
;
338 static int fbnic_hwtstamp_set(struct net_device
*netdev
,
339 struct kernel_hwtstamp_config
*config
,
340 struct netlink_ext_ack
*extack
)
342 struct fbnic_net
*fbn
= netdev_priv(netdev
);
345 if (config
->source
!= HWTSTAMP_SOURCE_NETDEV
)
348 if (!kernel_hwtstamp_config_changed(config
, &fbn
->hwtstamp_config
))
351 /* Upscale the filters */
352 switch (config
->rx_filter
) {
353 case HWTSTAMP_FILTER_NONE
:
354 case HWTSTAMP_FILTER_ALL
:
355 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT
:
356 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT
:
357 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT
:
358 case HWTSTAMP_FILTER_PTP_V2_EVENT
:
360 case HWTSTAMP_FILTER_NTP_ALL
:
361 config
->rx_filter
= HWTSTAMP_FILTER_ALL
;
363 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC
:
364 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ
:
365 config
->rx_filter
= HWTSTAMP_FILTER_PTP_V1_L4_EVENT
;
367 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC
:
368 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ
:
369 config
->rx_filter
= HWTSTAMP_FILTER_PTP_V2_L4_EVENT
;
371 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC
:
372 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ
:
373 config
->rx_filter
= HWTSTAMP_FILTER_PTP_V2_L2_EVENT
;
375 case HWTSTAMP_FILTER_PTP_V2_SYNC
:
376 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ
:
377 config
->rx_filter
= HWTSTAMP_FILTER_PTP_V2_EVENT
;
384 old_rx_filter
= fbn
->hwtstamp_config
.rx_filter
;
385 memcpy(&fbn
->hwtstamp_config
, config
, sizeof(*config
));
387 if (old_rx_filter
!= config
->rx_filter
&& netif_running(fbn
->netdev
)) {
388 fbnic_rss_reinit(fbn
->fbd
, fbn
);
389 fbnic_write_rules(fbn
->fbd
);
392 /* Save / report back filter configuration
393 * Note that our filter configuration is inexact. Instead of
394 * filtering for a specific UDP port or L2 Ethertype we are
395 * filtering in all UDP or all non-IP packets for timestamping. So
396 * if anything other than FILTER_ALL is requested we report
397 * FILTER_SOME indicating that we will be timestamping a few
398 * additional packets.
400 if (config
->rx_filter
> HWTSTAMP_FILTER_ALL
)
401 config
->rx_filter
= HWTSTAMP_FILTER_SOME
;
406 static void fbnic_get_stats64(struct net_device
*dev
,
407 struct rtnl_link_stats64
*stats64
)
409 u64 tx_bytes
, tx_packets
, tx_dropped
= 0;
410 u64 rx_bytes
, rx_packets
, rx_dropped
= 0;
411 struct fbnic_net
*fbn
= netdev_priv(dev
);
412 struct fbnic_queue_stats
*stats
;
413 unsigned int start
, i
;
415 stats
= &fbn
->tx_stats
;
417 tx_bytes
= stats
->bytes
;
418 tx_packets
= stats
->packets
;
419 tx_dropped
= stats
->dropped
;
421 stats64
->tx_bytes
= tx_bytes
;
422 stats64
->tx_packets
= tx_packets
;
423 stats64
->tx_dropped
= tx_dropped
;
425 for (i
= 0; i
< fbn
->num_tx_queues
; i
++) {
426 struct fbnic_ring
*txr
= fbn
->tx
[i
];
433 start
= u64_stats_fetch_begin(&stats
->syncp
);
434 tx_bytes
= stats
->bytes
;
435 tx_packets
= stats
->packets
;
436 tx_dropped
= stats
->dropped
;
437 } while (u64_stats_fetch_retry(&stats
->syncp
, start
));
439 stats64
->tx_bytes
+= tx_bytes
;
440 stats64
->tx_packets
+= tx_packets
;
441 stats64
->tx_dropped
+= tx_dropped
;
444 stats
= &fbn
->rx_stats
;
446 rx_bytes
= stats
->bytes
;
447 rx_packets
= stats
->packets
;
448 rx_dropped
= stats
->dropped
;
450 stats64
->rx_bytes
= rx_bytes
;
451 stats64
->rx_packets
= rx_packets
;
452 stats64
->rx_dropped
= rx_dropped
;
454 for (i
= 0; i
< fbn
->num_rx_queues
; i
++) {
455 struct fbnic_ring
*rxr
= fbn
->rx
[i
];
462 start
= u64_stats_fetch_begin(&stats
->syncp
);
463 rx_bytes
= stats
->bytes
;
464 rx_packets
= stats
->packets
;
465 rx_dropped
= stats
->dropped
;
466 } while (u64_stats_fetch_retry(&stats
->syncp
, start
));
468 stats64
->rx_bytes
+= rx_bytes
;
469 stats64
->rx_packets
+= rx_packets
;
470 stats64
->rx_dropped
+= rx_dropped
;
474 static const struct net_device_ops fbnic_netdev_ops
= {
475 .ndo_open
= fbnic_open
,
476 .ndo_stop
= fbnic_stop
,
477 .ndo_validate_addr
= eth_validate_addr
,
478 .ndo_start_xmit
= fbnic_xmit_frame
,
479 .ndo_features_check
= fbnic_features_check
,
480 .ndo_set_mac_address
= fbnic_set_mac
,
481 .ndo_set_rx_mode
= fbnic_set_rx_mode
,
482 .ndo_get_stats64
= fbnic_get_stats64
,
483 .ndo_hwtstamp_get
= fbnic_hwtstamp_get
,
484 .ndo_hwtstamp_set
= fbnic_hwtstamp_set
,
487 static void fbnic_get_queue_stats_rx(struct net_device
*dev
, int idx
,
488 struct netdev_queue_stats_rx
*rx
)
490 struct fbnic_net
*fbn
= netdev_priv(dev
);
491 struct fbnic_ring
*rxr
= fbn
->rx
[idx
];
492 struct fbnic_queue_stats
*stats
;
501 start
= u64_stats_fetch_begin(&stats
->syncp
);
502 bytes
= stats
->bytes
;
503 packets
= stats
->packets
;
504 } while (u64_stats_fetch_retry(&stats
->syncp
, start
));
507 rx
->packets
= packets
;
510 static void fbnic_get_queue_stats_tx(struct net_device
*dev
, int idx
,
511 struct netdev_queue_stats_tx
*tx
)
513 struct fbnic_net
*fbn
= netdev_priv(dev
);
514 struct fbnic_ring
*txr
= fbn
->tx
[idx
];
515 struct fbnic_queue_stats
*stats
;
524 start
= u64_stats_fetch_begin(&stats
->syncp
);
525 bytes
= stats
->bytes
;
526 packets
= stats
->packets
;
527 } while (u64_stats_fetch_retry(&stats
->syncp
, start
));
530 tx
->packets
= packets
;
533 static void fbnic_get_base_stats(struct net_device
*dev
,
534 struct netdev_queue_stats_rx
*rx
,
535 struct netdev_queue_stats_tx
*tx
)
537 struct fbnic_net
*fbn
= netdev_priv(dev
);
539 tx
->bytes
= fbn
->tx_stats
.bytes
;
540 tx
->packets
= fbn
->tx_stats
.packets
;
542 rx
->bytes
= fbn
->rx_stats
.bytes
;
543 rx
->packets
= fbn
->rx_stats
.packets
;
546 static const struct netdev_stat_ops fbnic_stat_ops
= {
547 .get_queue_stats_rx
= fbnic_get_queue_stats_rx
,
548 .get_queue_stats_tx
= fbnic_get_queue_stats_tx
,
549 .get_base_stats
= fbnic_get_base_stats
,
552 void fbnic_reset_queues(struct fbnic_net
*fbn
,
553 unsigned int tx
, unsigned int rx
)
555 struct fbnic_dev
*fbd
= fbn
->fbd
;
556 unsigned int max_napis
;
558 max_napis
= fbd
->num_irqs
- FBNIC_NON_NAPI_VECTORS
;
560 tx
= min(tx
, max_napis
);
561 fbn
->num_tx_queues
= tx
;
563 rx
= min(rx
, max_napis
);
564 fbn
->num_rx_queues
= rx
;
566 fbn
->num_napi
= max(tx
, rx
);
570 * fbnic_netdev_free - Free the netdev associate with fbnic
571 * @fbd: Driver specific structure to free netdev from
573 * Allocate and initialize the netdev and netdev private structure. Bind
574 * together the hardware, netdev, and pci data structures.
576 void fbnic_netdev_free(struct fbnic_dev
*fbd
)
578 struct fbnic_net
*fbn
= netdev_priv(fbd
->netdev
);
581 phylink_destroy(fbn
->phylink
);
583 free_netdev(fbd
->netdev
);
588 * fbnic_netdev_alloc - Allocate a netdev and associate with fbnic
589 * @fbd: Driver specific structure to associate netdev with
591 * Allocate and initialize the netdev and netdev private structure. Bind
592 * together the hardware, netdev, and pci data structures.
594 * Return: 0 on success, negative on failure
596 struct net_device
*fbnic_netdev_alloc(struct fbnic_dev
*fbd
)
598 struct net_device
*netdev
;
599 struct fbnic_net
*fbn
;
602 netdev
= alloc_etherdev_mq(sizeof(*fbn
), FBNIC_MAX_RXQS
);
606 SET_NETDEV_DEV(netdev
, fbd
->dev
);
607 fbd
->netdev
= netdev
;
609 netdev
->netdev_ops
= &fbnic_netdev_ops
;
610 netdev
->stat_ops
= &fbnic_stat_ops
;
612 fbnic_set_ethtool_ops(netdev
);
614 fbn
= netdev_priv(netdev
);
616 fbn
->netdev
= netdev
;
618 INIT_LIST_HEAD(&fbn
->napis
);
620 fbn
->txq_size
= FBNIC_TXQ_SIZE_DEFAULT
;
621 fbn
->hpq_size
= FBNIC_HPQ_SIZE_DEFAULT
;
622 fbn
->ppq_size
= FBNIC_PPQ_SIZE_DEFAULT
;
623 fbn
->rcq_size
= FBNIC_RCQ_SIZE_DEFAULT
;
625 default_queues
= netif_get_num_default_rss_queues();
626 if (default_queues
> fbd
->max_num_queues
)
627 default_queues
= fbd
->max_num_queues
;
629 fbnic_reset_queues(fbn
, default_queues
, default_queues
);
631 fbnic_reset_indir_tbl(fbn
);
632 fbnic_rss_key_fill(fbn
->rss_key
);
633 fbnic_rss_init_en_mask(fbn
);
641 netdev
->hw_features
|= netdev
->features
;
642 netdev
->vlan_features
|= netdev
->features
;
643 netdev
->hw_enc_features
|= netdev
->features
;
645 netdev
->min_mtu
= IPV6_MIN_MTU
;
646 netdev
->max_mtu
= FBNIC_MAX_JUMBO_FRAME_SIZE
- ETH_HLEN
;
648 /* TBD: This is workaround for BMC as phylink doesn't have support
649 * for leavling the link enabled if a BMC is present.
651 netdev
->ethtool
->wol_enabled
= true;
653 fbn
->fec
= FBNIC_FEC_AUTO
| FBNIC_FEC_RS
;
654 fbn
->link_mode
= FBNIC_LINK_AUTO
| FBNIC_LINK_50R2
;
655 netif_carrier_off(netdev
);
657 netif_tx_stop_all_queues(netdev
);
659 if (fbnic_phylink_init(netdev
)) {
660 fbnic_netdev_free(fbd
);
667 static int fbnic_dsn_to_mac_addr(u64 dsn
, char *addr
)
669 addr
[0] = (dsn
>> 56) & 0xFF;
670 addr
[1] = (dsn
>> 48) & 0xFF;
671 addr
[2] = (dsn
>> 40) & 0xFF;
672 addr
[3] = (dsn
>> 16) & 0xFF;
673 addr
[4] = (dsn
>> 8) & 0xFF;
674 addr
[5] = dsn
& 0xFF;
676 return is_valid_ether_addr(addr
) ? 0 : -EINVAL
;
680 * fbnic_netdev_register - Initialize general software structures
681 * @netdev: Netdev containing structure to initialize and register
683 * Initialize the MAC address for the netdev and register it.
685 * Return: 0 on success, negative on failure
687 int fbnic_netdev_register(struct net_device
*netdev
)
689 struct fbnic_net
*fbn
= netdev_priv(netdev
);
690 struct fbnic_dev
*fbd
= fbn
->fbd
;
695 err
= fbnic_dsn_to_mac_addr(dsn
, addr
);
697 ether_addr_copy(netdev
->perm_addr
, addr
);
698 eth_hw_addr_set(netdev
, addr
);
700 /* A randomly assigned MAC address will cause provisioning
701 * issues so instead just fail to spawn the netdev and
702 * avoid any confusion.
704 dev_err(fbd
->dev
, "MAC addr %pM invalid\n", addr
);
708 return register_netdev(netdev
);
711 void fbnic_netdev_unregister(struct net_device
*netdev
)
713 unregister_netdev(netdev
);