Skip to content

Commit 39709fe

Browse files
Jiawen WuPaolo Abeni
authored andcommitted
net: txgbe: Distinguish between 40G and 25G devices
For the following patches to support PHYLINK for AML 25G devices, separate MAC type wx_mac_aml40 to maintain the driver of 40G devices. Because 40G devices will complete support later, not now. And this patch makes the 25G devices use some PHYLINK interfaces, but it is not yet create PHYLINK and cannot be used on its own. It is just preparation for the next patches. Signed-off-by: Jiawen Wu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 78cafb1 commit 39709fe

File tree

8 files changed

+61
-26
lines changed

8 files changed

+61
-26
lines changed

drivers/net/ethernet/wangxun/libwx/wx_ethtool.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ int wx_nway_reset(struct net_device *netdev)
219219
{
220220
struct wx *wx = netdev_priv(netdev);
221221

222-
if (wx->mac.type == wx_mac_aml)
222+
if (wx->mac.type == wx_mac_aml40)
223223
return -EOPNOTSUPP;
224224

225225
return phylink_ethtool_nway_reset(wx->phylink);
@@ -231,7 +231,7 @@ int wx_get_link_ksettings(struct net_device *netdev,
231231
{
232232
struct wx *wx = netdev_priv(netdev);
233233

234-
if (wx->mac.type == wx_mac_aml)
234+
if (wx->mac.type == wx_mac_aml40)
235235
return -EOPNOTSUPP;
236236

237237
return phylink_ethtool_ksettings_get(wx->phylink, cmd);
@@ -243,7 +243,7 @@ int wx_set_link_ksettings(struct net_device *netdev,
243243
{
244244
struct wx *wx = netdev_priv(netdev);
245245

246-
if (wx->mac.type == wx_mac_aml)
246+
if (wx->mac.type == wx_mac_aml40)
247247
return -EOPNOTSUPP;
248248

249249
return phylink_ethtool_ksettings_set(wx->phylink, cmd);
@@ -255,7 +255,7 @@ void wx_get_pauseparam(struct net_device *netdev,
255255
{
256256
struct wx *wx = netdev_priv(netdev);
257257

258-
if (wx->mac.type == wx_mac_aml)
258+
if (wx->mac.type == wx_mac_aml40)
259259
return;
260260

261261
phylink_ethtool_get_pauseparam(wx->phylink, pause);
@@ -267,7 +267,7 @@ int wx_set_pauseparam(struct net_device *netdev,
267267
{
268268
struct wx *wx = netdev_priv(netdev);
269269

270-
if (wx->mac.type == wx_mac_aml)
270+
if (wx->mac.type == wx_mac_aml40)
271271
return -EOPNOTSUPP;
272272

273273
return phylink_ethtool_set_pauseparam(wx->phylink, pause);
@@ -345,6 +345,7 @@ int wx_set_coalesce(struct net_device *netdev,
345345
max_eitr = WX_SP_MAX_EITR;
346346
break;
347347
case wx_mac_aml:
348+
case wx_mac_aml40:
348349
max_eitr = WX_AML_MAX_EITR;
349350
break;
350351
default:
@@ -375,6 +376,7 @@ int wx_set_coalesce(struct net_device *netdev,
375376
switch (wx->mac.type) {
376377
case wx_mac_sp:
377378
case wx_mac_aml:
379+
case wx_mac_aml40:
378380
tx_itr_param = WX_12K_ITR;
379381
break;
380382
default:

drivers/net/ethernet/wangxun/libwx/wx_hw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ void wx_init_eeprom_params(struct wx *wx)
695695
switch (wx->mac.type) {
696696
case wx_mac_sp:
697697
case wx_mac_aml:
698+
case wx_mac_aml40:
698699
if (wx_read_ee_hostif(wx, WX_SW_REGION_PTR, &data)) {
699700
wx_err(wx, "NVM Read Error\n");
700701
return;

drivers/net/ethernet/wangxun/libwx/wx_lib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ static int wx_alloc_q_vector(struct wx *wx,
19591959
switch (wx->mac.type) {
19601960
case wx_mac_sp:
19611961
case wx_mac_aml:
1962+
case wx_mac_aml40:
19621963
default_itr = WX_12K_ITR;
19631964
break;
19641965
default:
@@ -2327,6 +2328,7 @@ void wx_write_eitr(struct wx_q_vector *q_vector)
23272328
itr_reg = q_vector->itr & WX_SP_MAX_EITR;
23282329
break;
23292330
case wx_mac_aml:
2331+
case wx_mac_aml40:
23302332
itr_reg = (q_vector->itr >> 3) & WX_AML_MAX_EITR;
23312333
break;
23322334
default:

drivers/net/ethernet/wangxun/libwx/wx_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ enum wx_mac_type {
838838
wx_mac_sp,
839839
wx_mac_em,
840840
wx_mac_aml,
841+
wx_mac_aml40,
841842
};
842843

843844
enum wx_media_type {

drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void txgbe_del_irq_domain(struct txgbe *txgbe)
176176

177177
void txgbe_free_misc_irq(struct txgbe *txgbe)
178178
{
179-
if (txgbe->wx->mac.type == wx_mac_aml)
179+
if (txgbe->wx->mac.type == wx_mac_aml40)
180180
return;
181181

182182
free_irq(txgbe->link_irq, txgbe);
@@ -190,7 +190,7 @@ int txgbe_setup_misc_irq(struct txgbe *txgbe)
190190
struct wx *wx = txgbe->wx;
191191
int hwirq, err;
192192

193-
if (wx->mac.type == wx_mac_aml)
193+
if (wx->mac.type == wx_mac_aml40)
194194
goto skip_sp_irq;
195195

196196
txgbe->misc.nirqs = TXGBE_IRQ_MAX;

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static int txgbe_enumerate_functions(struct wx *wx)
9191
static void txgbe_up_complete(struct wx *wx)
9292
{
9393
struct net_device *netdev = wx->netdev;
94+
u32 reg;
9495

9596
wx_control_hw(wx, true);
9697
wx_configure_vectors(wx);
@@ -99,17 +100,21 @@ static void txgbe_up_complete(struct wx *wx)
99100
smp_mb__before_atomic();
100101
wx_napi_enable_all(wx);
101102

102-
if (wx->mac.type == wx_mac_aml) {
103-
u32 reg;
104-
103+
switch (wx->mac.type) {
104+
case wx_mac_aml40:
105105
reg = rd32(wx, TXGBE_AML_MAC_TX_CFG);
106106
reg &= ~TXGBE_AML_MAC_TX_CFG_SPEED_MASK;
107-
reg |= TXGBE_AML_MAC_TX_CFG_SPEED_25G;
107+
reg |= TXGBE_AML_MAC_TX_CFG_SPEED_40G;
108108
wr32(wx, WX_MAC_TX_CFG, reg);
109109
txgbe_enable_sec_tx_path(wx);
110110
netif_carrier_on(wx->netdev);
111-
} else {
111+
break;
112+
case wx_mac_aml:
113+
case wx_mac_sp:
112114
phylink_start(wx->phylink);
115+
break;
116+
default:
117+
break;
113118
}
114119

115120
/* clear any pending interrupts, may auto mask */
@@ -207,10 +212,18 @@ void txgbe_down(struct wx *wx)
207212
{
208213
txgbe_disable_device(wx);
209214
txgbe_reset(wx);
210-
if (wx->mac.type == wx_mac_aml)
215+
216+
switch (wx->mac.type) {
217+
case wx_mac_aml40:
211218
netif_carrier_off(wx->netdev);
212-
else
219+
break;
220+
case wx_mac_aml:
221+
case wx_mac_sp:
213222
phylink_stop(wx->phylink);
223+
break;
224+
default:
225+
break;
226+
}
214227

215228
wx_clean_all_tx_rings(wx);
216229
wx_clean_all_rx_rings(wx);
@@ -240,9 +253,11 @@ static void txgbe_init_type_code(struct wx *wx)
240253
case TXGBE_DEV_ID_AML5110:
241254
case TXGBE_DEV_ID_AML5025:
242255
case TXGBE_DEV_ID_AML5125:
256+
wx->mac.type = wx_mac_aml;
257+
break;
243258
case TXGBE_DEV_ID_AML5040:
244259
case TXGBE_DEV_ID_AML5140:
245-
wx->mac.type = wx_mac_aml;
260+
wx->mac.type = wx_mac_aml40;
246261
break;
247262
default:
248263
wx->mac.type = wx_mac_unknown;
@@ -341,6 +356,7 @@ static int txgbe_sw_init(struct wx *wx)
341356
case wx_mac_sp:
342357
break;
343358
case wx_mac_aml:
359+
case wx_mac_aml40:
344360
set_bit(WX_FLAG_SWFW_RING, wx->flags);
345361
wx->swfw_index = 0;
346362
break;

drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,17 @@ int txgbe_init_phy(struct txgbe *txgbe)
573573
struct wx *wx = txgbe->wx;
574574
int ret;
575575

576-
if (wx->mac.type == wx_mac_aml)
576+
switch (wx->mac.type) {
577+
case wx_mac_aml40:
578+
case wx_mac_aml:
577579
return 0;
578-
579-
if (txgbe->wx->media_type == wx_media_copper)
580-
return txgbe_ext_phy_init(txgbe);
580+
case wx_mac_sp:
581+
if (wx->media_type == wx_media_copper)
582+
return txgbe_ext_phy_init(txgbe);
583+
break;
584+
default:
585+
break;
586+
}
581587

582588
ret = txgbe_swnodes_register(txgbe);
583589
if (ret) {
@@ -640,13 +646,19 @@ int txgbe_init_phy(struct txgbe *txgbe)
640646

641647
void txgbe_remove_phy(struct txgbe *txgbe)
642648
{
643-
if (txgbe->wx->mac.type == wx_mac_aml)
644-
return;
645-
646-
if (txgbe->wx->media_type == wx_media_copper) {
647-
phylink_disconnect_phy(txgbe->wx->phylink);
648-
phylink_destroy(txgbe->wx->phylink);
649+
switch (txgbe->wx->mac.type) {
650+
case wx_mac_aml40:
651+
case wx_mac_aml:
649652
return;
653+
case wx_mac_sp:
654+
if (txgbe->wx->media_type == wx_media_copper) {
655+
phylink_disconnect_phy(txgbe->wx->phylink);
656+
phylink_destroy(txgbe->wx->phylink);
657+
return;
658+
}
659+
break;
660+
default:
661+
break;
650662
}
651663

652664
platform_device_unregister(txgbe->sfp_dev);

drivers/net/ethernet/wangxun/txgbe/txgbe_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@
152152
#define TXGBE_PX_PF_BME 0x4B8
153153
#define TXGBE_AML_MAC_TX_CFG 0x11000
154154
#define TXGBE_AML_MAC_TX_CFG_SPEED_MASK GENMASK(30, 27)
155-
#define TXGBE_AML_MAC_TX_CFG_SPEED_25G BIT(28)
155+
#define TXGBE_AML_MAC_TX_CFG_SPEED_40G FIELD_PREP(GENMASK(30, 27), 0)
156+
#define TXGBE_AML_MAC_TX_CFG_SPEED_25G FIELD_PREP(GENMASK(30, 27), 2)
156157
#define TXGBE_RDM_RSC_CTL 0x1200C
157158
#define TXGBE_RDM_RSC_CTL_FREE_CTL BIT(7)
158159

0 commit comments

Comments
 (0)