Skip to content

Commit 06aee7f

Browse files
ahduyckNipaLocal
authored andcommitted
fbnic: Retire "AUTO" flags and cleanup handling of FW link settings
There were several issues in the way we were handling the link info coming from firmware. First is the fact that we were carrying around "AUTO" flags to indicate that we needed to populate the values. We can just drop this and assume that we will always be populating the settings from firmware. With this we can also clean up the masking as the "AUTO" flags were just there to be stripped anyway. Second since we are getting rid of the "AUTO" setting we still need a way to report that the link is not configured. We convert the link_mode "AUTO" to "UNKNOWN" to do this. With this we can avoid reporting link up in the phylink_pcs_get_state call as we will just set link to 0 and return without updating the link speed. This is preferred versus the driver just forcing 50G which makes it harder to recover when the FW does start providing valid settings. With this the plan is to eventually replace the link_mode we use with the interface_mode from phylink for all intents and purposes and have the two be interchangeable. At that point we can convert the FW provided settings over to something closer to link partner settings and give phylink greater control of the interface allowing for user override of the settings and an asynchronous setup of the link versus having to pull early settings from firmware. Signed-off-by: Alexander Duyck <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 4287262 commit 06aee7f

File tree

4 files changed

+48
-66
lines changed

4 files changed

+48
-66
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_mac.c

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static u32 __fbnic_mac_cmd_config_asic(struct fbnic_dev *fbd,
452452
command_config |= FBNIC_MAC_COMMAND_CONFIG_RX_PAUSE_DIS;
453453

454454
/* Disable fault handling if no FEC is requested */
455-
if ((fbn->fec & FBNIC_FEC_MODE_MASK) == FBNIC_FEC_OFF)
455+
if (fbn->fec == FBNIC_FEC_OFF)
456456
command_config |= FBNIC_MAC_COMMAND_CONFIG_FLT_HDL_DIS;
457457

458458
return command_config;
@@ -468,15 +468,15 @@ static bool fbnic_mac_get_pcs_link_status(struct fbnic_dev *fbd)
468468
return false;
469469

470470
/* Define the expected lane mask for the status bits we need to check */
471-
switch (fbn->link_mode & FBNIC_LINK_MODE_MASK) {
471+
switch (fbn->link_mode) {
472472
case FBNIC_LINK_100R2:
473473
lane_mask = 0xf;
474474
break;
475475
case FBNIC_LINK_50R1:
476476
lane_mask = 3;
477477
break;
478478
case FBNIC_LINK_50R2:
479-
switch (fbn->fec & FBNIC_FEC_MODE_MASK) {
479+
switch (fbn->fec) {
480480
case FBNIC_FEC_OFF:
481481
lane_mask = 0x63;
482482
break;
@@ -494,7 +494,7 @@ static bool fbnic_mac_get_pcs_link_status(struct fbnic_dev *fbd)
494494
}
495495

496496
/* Use an XOR to remove the bits we expect to see set */
497-
switch (fbn->fec & FBNIC_FEC_MODE_MASK) {
497+
switch (fbn->fec) {
498498
case FBNIC_FEC_OFF:
499499
lane_mask ^= FIELD_GET(FBNIC_SIG_PCS_OUT0_BLOCK_LOCK,
500500
pcs_status);
@@ -540,64 +540,55 @@ static bool fbnic_pcs_get_link_asic(struct fbnic_dev *fbd)
540540
return link;
541541
}
542542

543-
static void fbnic_pcs_get_fw_settings(struct fbnic_dev *fbd)
543+
static void
544+
fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *link_mode, u8 *fec)
544545
{
545-
struct fbnic_net *fbn = netdev_priv(fbd->netdev);
546-
u8 link_mode = fbn->link_mode;
547-
u8 fec = fbn->fec;
548-
549-
/* Update FEC first to reflect FW current mode */
550-
if (fbn->fec & FBNIC_FEC_AUTO) {
551-
switch (fbd->fw_cap.link_fec) {
552-
case FBNIC_FW_LINK_FEC_NONE:
553-
fec = FBNIC_FEC_OFF;
554-
break;
555-
case FBNIC_FW_LINK_FEC_RS:
556-
fec = FBNIC_FEC_RS;
557-
break;
558-
case FBNIC_FW_LINK_FEC_BASER:
559-
fec = FBNIC_FEC_BASER;
560-
break;
561-
default:
562-
return;
563-
}
564-
565-
fbn->fec = fec;
546+
/* Retrieve default speed from FW */
547+
switch (fbd->fw_cap.link_speed) {
548+
case FBNIC_FW_LINK_SPEED_25R1:
549+
*link_mode = FBNIC_LINK_25R1;
550+
break;
551+
case FBNIC_FW_LINK_SPEED_50R2:
552+
*link_mode = FBNIC_LINK_50R2;
553+
break;
554+
case FBNIC_FW_LINK_SPEED_50R1:
555+
*link_mode = FBNIC_LINK_50R1;
556+
*fec = FBNIC_FEC_RS;
557+
return;
558+
case FBNIC_FW_LINK_SPEED_100R2:
559+
*link_mode = FBNIC_LINK_100R2;
560+
*fec = FBNIC_FEC_RS;
561+
return;
562+
default:
563+
*link_mode = FBNIC_LINK_UNKONWN;
564+
return;
566565
}
567566

568-
/* Do nothing if AUTO mode is not engaged */
569-
if (fbn->link_mode & FBNIC_LINK_AUTO) {
570-
switch (fbd->fw_cap.link_speed) {
571-
case FBNIC_FW_LINK_SPEED_25R1:
572-
link_mode = FBNIC_LINK_25R1;
573-
break;
574-
case FBNIC_FW_LINK_SPEED_50R2:
575-
link_mode = FBNIC_LINK_50R2;
576-
break;
577-
case FBNIC_FW_LINK_SPEED_50R1:
578-
link_mode = FBNIC_LINK_50R1;
579-
fec = FBNIC_FEC_RS;
580-
break;
581-
case FBNIC_FW_LINK_SPEED_100R2:
582-
link_mode = FBNIC_LINK_100R2;
583-
fec = FBNIC_FEC_RS;
584-
break;
585-
default:
586-
return;
587-
}
588-
589-
fbn->link_mode = link_mode;
567+
/* Update FEC first to reflect FW current mode */
568+
switch (fbd->fw_cap.link_fec) {
569+
case FBNIC_FW_LINK_FEC_NONE:
570+
*fec = FBNIC_FEC_OFF;
571+
break;
572+
case FBNIC_FW_LINK_FEC_RS:
573+
default:
574+
*fec = FBNIC_FEC_RS;
575+
break;
576+
case FBNIC_FW_LINK_FEC_BASER:
577+
*fec = FBNIC_FEC_BASER;
578+
break;
590579
}
591580
}
592581

593582
static int fbnic_pcs_enable_asic(struct fbnic_dev *fbd)
594583
{
584+
struct fbnic_net *fbn = netdev_priv(fbd->netdev);
585+
595586
/* Mask and clear the PCS interrupt, will be enabled by link handler */
596587
wr32(fbd, FBNIC_SIG_PCS_INTR_MASK, ~0);
597588
wr32(fbd, FBNIC_SIG_PCS_INTR_STS, ~0);
598589

599590
/* Pull in settings from FW */
600-
fbnic_pcs_get_fw_settings(fbd);
591+
fbnic_mac_get_fw_settings(fbd, &fbn->link_mode, &fbn->fec);
601592

602593
return 0;
603594
}

drivers/net/ethernet/meta/fbnic/fbnic_mac.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ enum {
2525
FBNIC_FEC_OFF = 0,
2626
FBNIC_FEC_RS = 1,
2727
FBNIC_FEC_BASER = 2,
28-
FBNIC_FEC_AUTO = 4,
2928
};
3029

31-
#define FBNIC_FEC_MODE_MASK (FBNIC_FEC_AUTO - 1)
32-
3330
/* Treat the link modes as a set of modulation/lanes bitmask:
3431
* Bit 0: Lane Count, 0 = R1, 1 = R2
3532
* Bit 1: Modulation, 0 = NRZ, 1 = PAM4
@@ -40,12 +37,11 @@ enum {
4037
FBNIC_LINK_50R2 = 1,
4138
FBNIC_LINK_50R1 = 2,
4239
FBNIC_LINK_100R2 = 3,
43-
FBNIC_LINK_AUTO = 4,
40+
FBNIC_LINK_UNKONWN = 4,
4441
};
4542

4643
#define FBNIC_LINK_MODE_R2 (FBNIC_LINK_50R2)
4744
#define FBNIC_LINK_MODE_PAM4 (FBNIC_LINK_50R1)
48-
#define FBNIC_LINK_MODE_MASK (FBNIC_LINK_AUTO - 1)
4945

5046
enum fbnic_sensor_id {
5147
FBNIC_SENSOR_TEMP, /* Temp in millidegrees Centigrade */

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,6 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
736736
*/
737737
netdev->ethtool->wol_enabled = true;
738738

739-
fbn->fec = FBNIC_FEC_AUTO | FBNIC_FEC_RS;
740-
fbn->link_mode = FBNIC_LINK_AUTO | FBNIC_LINK_50R2;
741739
netif_carrier_off(netdev);
742740

743741
netif_tx_stop_all_queues(netdev);

drivers/net/ethernet/meta/fbnic/fbnic_phylink.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ fbnic_phylink_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
2121
struct fbnic_net *fbn = fbnic_pcs_to_net(pcs);
2222
struct fbnic_dev *fbd = fbn->fbd;
2323

24-
/* For now we use hard-coded defaults and FW config to determine
25-
* the current values. In future patches we will add support for
26-
* reconfiguring these values and changing link settings.
27-
*/
28-
switch (fbd->fw_cap.link_speed) {
29-
case FBNIC_FW_LINK_SPEED_25R1:
24+
switch (fbn->link_mode) {
25+
case FBNIC_LINK_25R1:
3026
state->speed = SPEED_25000;
3127
break;
32-
case FBNIC_FW_LINK_SPEED_50R2:
28+
case FBNIC_LINK_50R2:
29+
case FBNIC_LINK_50R1:
3330
state->speed = SPEED_50000;
3431
break;
35-
case FBNIC_FW_LINK_SPEED_100R2:
32+
case FBNIC_LINK_100R2:
3633
state->speed = SPEED_100000;
3734
break;
3835
default:
39-
state->speed = SPEED_UNKNOWN;
40-
break;
36+
state->link = 0;
37+
return;
4138
}
4239

4340
state->duplex = DUPLEX_FULL;

0 commit comments

Comments
 (0)