Skip to content

Commit e272bbc

Browse files
author
Paolo Abeni
committed
Merge branch 'add-functions-for-txgbe-aml-devices'
Jiawen Wu says: ==================== Support phylink and link/gpio irqs for AML 25G/10G devices, and complete PTP and SRIOV. ==================== Link: https://patch.msgid.link/ Signed-off-by: Paolo Abeni <[email protected]>
2 parents e8c35bf + cdae5bc commit e272bbc

File tree

18 files changed

+831
-113
lines changed

18 files changed

+831
-113
lines changed

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

Lines changed: 8 additions & 14 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,9 +231,6 @@ 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)
235-
return -EOPNOTSUPP;
236-
237234
return phylink_ethtool_ksettings_get(wx->phylink, cmd);
238235
}
239236
EXPORT_SYMBOL(wx_get_link_ksettings);
@@ -243,7 +240,7 @@ int wx_set_link_ksettings(struct net_device *netdev,
243240
{
244241
struct wx *wx = netdev_priv(netdev);
245242

246-
if (wx->mac.type == wx_mac_aml)
243+
if (wx->mac.type == wx_mac_aml40)
247244
return -EOPNOTSUPP;
248245

249246
return phylink_ethtool_ksettings_set(wx->phylink, cmd);
@@ -255,7 +252,7 @@ void wx_get_pauseparam(struct net_device *netdev,
255252
{
256253
struct wx *wx = netdev_priv(netdev);
257254

258-
if (wx->mac.type == wx_mac_aml)
255+
if (wx->mac.type == wx_mac_aml40)
259256
return;
260257

261258
phylink_ethtool_get_pauseparam(wx->phylink, pause);
@@ -267,7 +264,7 @@ int wx_set_pauseparam(struct net_device *netdev,
267264
{
268265
struct wx *wx = netdev_priv(netdev);
269266

270-
if (wx->mac.type == wx_mac_aml)
267+
if (wx->mac.type == wx_mac_aml40)
271268
return -EOPNOTSUPP;
272269

273270
return phylink_ethtool_set_pauseparam(wx->phylink, pause);
@@ -345,6 +342,7 @@ int wx_set_coalesce(struct net_device *netdev,
345342
max_eitr = WX_SP_MAX_EITR;
346343
break;
347344
case wx_mac_aml:
345+
case wx_mac_aml40:
348346
max_eitr = WX_AML_MAX_EITR;
349347
break;
350348
default:
@@ -375,6 +373,7 @@ int wx_set_coalesce(struct net_device *netdev,
375373
switch (wx->mac.type) {
376374
case wx_mac_sp:
377375
case wx_mac_aml:
376+
case wx_mac_aml40:
378377
tx_itr_param = WX_12K_ITR;
379378
break;
380379
default:
@@ -413,15 +412,10 @@ static unsigned int wx_max_channels(struct wx *wx)
413412
max_combined = 1;
414413
} else {
415414
/* support up to max allowed queues with RSS */
416-
switch (wx->mac.type) {
417-
case wx_mac_sp:
418-
case wx_mac_aml:
415+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
419416
max_combined = 63;
420-
break;
421-
default:
417+
else
422418
max_combined = 8;
423-
break;
424-
}
425419
}
426420

427421
return max_combined;

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

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,10 @@ static void wx_intr_disable(struct wx *wx, u64 qmask)
113113
if (mask)
114114
wr32(wx, WX_PX_IMS(0), mask);
115115

116-
switch (wx->mac.type) {
117-
case wx_mac_sp:
118-
case wx_mac_aml:
116+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
119117
mask = (qmask >> 32);
120118
if (mask)
121119
wr32(wx, WX_PX_IMS(1), mask);
122-
break;
123-
default:
124-
break;
125120
}
126121
}
127122

@@ -133,15 +128,10 @@ void wx_intr_enable(struct wx *wx, u64 qmask)
133128
if (mask)
134129
wr32(wx, WX_PX_IMC(0), mask);
135130

136-
switch (wx->mac.type) {
137-
case wx_mac_sp:
138-
case wx_mac_aml:
131+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
139132
mask = (qmask >> 32);
140133
if (mask)
141134
wr32(wx, WX_PX_IMC(1), mask);
142-
break;
143-
default:
144-
break;
145135
}
146136
}
147137
EXPORT_SYMBOL(wx_intr_enable);
@@ -705,6 +695,7 @@ void wx_init_eeprom_params(struct wx *wx)
705695
switch (wx->mac.type) {
706696
case wx_mac_sp:
707697
case wx_mac_aml:
698+
case wx_mac_aml40:
708699
if (wx_read_ee_hostif(wx, WX_SW_REGION_PTR, &data)) {
709700
wx_err(wx, "NVM Read Error\n");
710701
return;
@@ -774,14 +765,8 @@ static int wx_set_rar(struct wx *wx, u32 index, u8 *addr, u64 pools,
774765
/* setup VMDq pool mapping */
775766
wr32(wx, WX_PSR_MAC_SWC_VM_L, pools & 0xFFFFFFFF);
776767

777-
switch (wx->mac.type) {
778-
case wx_mac_sp:
779-
case wx_mac_aml:
768+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
780769
wr32(wx, WX_PSR_MAC_SWC_VM_H, pools >> 32);
781-
break;
782-
default:
783-
break;
784-
}
785770

786771
/* HW expects these in little endian so we reverse the byte
787772
* order from network order (big endian) to little endian
@@ -919,14 +904,9 @@ void wx_init_rx_addrs(struct wx *wx)
919904

920905
wx_set_rar(wx, 0, wx->mac.addr, 0, WX_PSR_MAC_SWC_AD_H_AV);
921906

922-
switch (wx->mac.type) {
923-
case wx_mac_sp:
924-
case wx_mac_aml:
907+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
925908
/* clear VMDq pool/queue selection for RAR 0 */
926909
wx_clear_vmdq(wx, 0, WX_CLEAR_VMDQ_ALL);
927-
break;
928-
default:
929-
break;
930910
}
931911
}
932912

@@ -1512,7 +1492,7 @@ static void wx_configure_virtualization(struct wx *wx)
15121492
wr32m(wx, WX_PSR_VM_L2CTL(pool),
15131493
WX_PSR_VM_L2CTL_AUPE, WX_PSR_VM_L2CTL_AUPE);
15141494

1515-
if (wx->mac.type == wx_mac_em) {
1495+
if (!test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
15161496
vf_shift = BIT(VMDQ_P(0));
15171497
/* Enable only the PF pools for Tx/Rx */
15181498
wr32(wx, WX_RDM_VF_RE(0), vf_shift);
@@ -1543,7 +1523,7 @@ static void wx_configure_port(struct wx *wx)
15431523
{
15441524
u32 value, i;
15451525

1546-
if (wx->mac.type == wx_mac_em) {
1526+
if (!test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
15471527
value = (wx->num_vfs == 0) ?
15481528
WX_CFG_PORT_CTL_NUM_VT_NONE :
15491529
WX_CFG_PORT_CTL_NUM_VT_8;
@@ -2074,7 +2054,7 @@ static void wx_setup_psrtype(struct wx *wx)
20742054
WX_RDB_PL_CFG_TUN_OUTL2HDR |
20752055
WX_RDB_PL_CFG_TUN_TUNHDR;
20762056

2077-
if (wx->mac.type == wx_mac_em) {
2057+
if (!test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
20782058
for_each_set_bit(pool, &wx->fwd_bitmask, 8)
20792059
wr32(wx, WX_RDB_PL_CFG(VMDQ_P(pool)), psrtype);
20802060
} else {
@@ -2272,10 +2252,8 @@ int wx_stop_adapter(struct wx *wx)
22722252
}
22732253
EXPORT_SYMBOL(wx_stop_adapter);
22742254

2275-
void wx_reset_misc(struct wx *wx)
2255+
void wx_reset_mac(struct wx *wx)
22762256
{
2277-
int i;
2278-
22792257
/* receive packets that size > 2048 */
22802258
wr32m(wx, WX_MAC_RX_CFG, WX_MAC_RX_CFG_JE, WX_MAC_RX_CFG_JE);
22812259

@@ -2287,6 +2265,14 @@ void wx_reset_misc(struct wx *wx)
22872265
WX_MAC_RX_FLOW_CTRL_RFE, WX_MAC_RX_FLOW_CTRL_RFE);
22882266

22892267
wr32(wx, WX_MAC_PKT_FLT, WX_MAC_PKT_FLT_PR);
2268+
}
2269+
EXPORT_SYMBOL(wx_reset_mac);
2270+
2271+
void wx_reset_misc(struct wx *wx)
2272+
{
2273+
int i;
2274+
2275+
wx_reset_mac(wx);
22902276

22912277
wr32m(wx, WX_MIS_RST_ST,
22922278
WX_MIS_RST_ST_RST_INIT, 0x1E00);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void wx_configure(struct wx *wx);
4242
void wx_start_hw(struct wx *wx);
4343
int wx_disable_pcie_master(struct wx *wx);
4444
int wx_stop_adapter(struct wx *wx);
45+
void wx_reset_mac(struct wx *wx);
4546
void wx_reset_misc(struct wx *wx);
4647
int wx_get_pcie_msix_counts(struct wx *wx, u16 *msix_count, u16 max_msix_count);
4748
int wx_sw_init(struct wx *wx);

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

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <net/ip6_checksum.h>
66
#include <net/page_pool/helpers.h>
77
#include <net/inet_ecn.h>
8+
#include <linux/workqueue.h>
89
#include <linux/iopoll.h>
910
#include <linux/sctp.h>
1011
#include <linux/pci.h>
@@ -1633,7 +1634,7 @@ static bool wx_set_vmdq_queues(struct wx *wx)
16331634
/* Add starting offset to total pool count */
16341635
vmdq_i += wx->ring_feature[RING_F_VMDQ].offset;
16351636

1636-
if (wx->mac.type == wx_mac_sp) {
1637+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
16371638
/* double check we are limited to maximum pools */
16381639
vmdq_i = min_t(u16, 64, vmdq_i);
16391640

@@ -1693,7 +1694,7 @@ static void wx_set_rss_queues(struct wx *wx)
16931694

16941695
/* set mask for 16 queue limit of RSS */
16951696
f = &wx->ring_feature[RING_F_RSS];
1696-
if (wx->mac.type == wx_mac_sp)
1697+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
16971698
f->mask = WX_RSS_64Q_MASK;
16981699
else
16991700
f->mask = WX_RSS_8Q_MASK;
@@ -1853,7 +1854,7 @@ static bool wx_cache_ring_vmdq(struct wx *wx)
18531854
if (!test_bit(WX_FLAG_VMDQ_ENABLED, wx->flags))
18541855
return false;
18551856

1856-
if (wx->mac.type == wx_mac_sp) {
1857+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
18571858
/* start at VMDq register offset for SR-IOV enabled setups */
18581859
reg_idx = vmdq->offset * __ALIGN_MASK(1, ~vmdq->mask);
18591860
for (i = 0; i < wx->num_rx_queues; i++, reg_idx++) {
@@ -1959,6 +1960,7 @@ static int wx_alloc_q_vector(struct wx *wx,
19591960
switch (wx->mac.type) {
19601961
case wx_mac_sp:
19611962
case wx_mac_aml:
1963+
case wx_mac_aml40:
19621964
default_itr = WX_12K_ITR;
19631965
break;
19641966
default:
@@ -2327,6 +2329,7 @@ void wx_write_eitr(struct wx_q_vector *q_vector)
23272329
itr_reg = q_vector->itr & WX_SP_MAX_EITR;
23282330
break;
23292331
case wx_mac_aml:
2332+
case wx_mac_aml40:
23302333
itr_reg = (q_vector->itr >> 3) & WX_AML_MAX_EITR;
23312334
break;
23322335
default:
@@ -2354,10 +2357,10 @@ void wx_configure_vectors(struct wx *wx)
23542357

23552358
if (pdev->msix_enabled) {
23562359
/* Populate MSIX to EITR Select */
2357-
if (wx->mac.type == wx_mac_sp) {
2360+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
23582361
if (wx->num_vfs >= 32)
23592362
eitrsel = BIT(wx->num_vfs % 32) - 1;
2360-
} else if (wx->mac.type == wx_mac_em) {
2363+
} else {
23612364
for (i = 0; i < wx->num_vfs; i++)
23622365
eitrsel |= BIT(i);
23632366
}
@@ -3093,5 +3096,35 @@ void wx_set_ring(struct wx *wx, u32 new_tx_count,
30933096
}
30943097
EXPORT_SYMBOL(wx_set_ring);
30953098

3099+
void wx_service_event_schedule(struct wx *wx)
3100+
{
3101+
if (!test_and_set_bit(WX_STATE_SERVICE_SCHED, wx->state))
3102+
queue_work(system_power_efficient_wq, &wx->service_task);
3103+
}
3104+
EXPORT_SYMBOL(wx_service_event_schedule);
3105+
3106+
void wx_service_event_complete(struct wx *wx)
3107+
{
3108+
if (WARN_ON(!test_bit(WX_STATE_SERVICE_SCHED, wx->state)))
3109+
return;
3110+
3111+
/* flush memory to make sure state is correct before next watchdog */
3112+
smp_mb__before_atomic();
3113+
clear_bit(WX_STATE_SERVICE_SCHED, wx->state);
3114+
}
3115+
EXPORT_SYMBOL(wx_service_event_complete);
3116+
3117+
void wx_service_timer(struct timer_list *t)
3118+
{
3119+
struct wx *wx = from_timer(wx, t, service_timer);
3120+
unsigned long next_event_offset = HZ * 2;
3121+
3122+
/* Reset the timer */
3123+
mod_timer(&wx->service_timer, next_event_offset + jiffies);
3124+
3125+
wx_service_event_schedule(wx);
3126+
}
3127+
EXPORT_SYMBOL(wx_service_timer);
3128+
30963129
MODULE_DESCRIPTION("Common library for Wangxun(R) Ethernet drivers.");
30973130
MODULE_LICENSE("GPL");

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ netdev_features_t wx_features_check(struct sk_buff *skb,
3838
netdev_features_t features);
3939
void wx_set_ring(struct wx *wx, u32 new_tx_count,
4040
u32 new_rx_count, struct wx_ring *temp_ring);
41+
void wx_service_event_schedule(struct wx *wx);
42+
void wx_service_event_complete(struct wx *wx);
43+
void wx_service_timer(struct timer_list *t);
4144

4245
#endif /* _WX_LIB_H_ */

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
#define WX_INCVAL_100 0xA00000
1616
#define WX_INCVAL_10 0xC7F380
1717
#define WX_INCVAL_EM 0x2000000
18+
#define WX_INCVAL_AML 0xA00000
1819

1920
#define WX_INCVAL_SHIFT_10GB 20
2021
#define WX_INCVAL_SHIFT_1GB 18
2122
#define WX_INCVAL_SHIFT_100 15
2223
#define WX_INCVAL_SHIFT_10 12
2324
#define WX_INCVAL_SHIFT_EM 22
25+
#define WX_INCVAL_SHIFT_AML 21
2426

2527
#define WX_OVERFLOW_PERIOD (HZ * 30)
2628
#define WX_PTP_TX_TIMEOUT (HZ)
@@ -504,15 +506,27 @@ static long wx_ptp_create_clock(struct wx *wx)
504506
wx->ptp_caps.gettimex64 = wx_ptp_gettimex64;
505507
wx->ptp_caps.settime64 = wx_ptp_settime64;
506508
wx->ptp_caps.do_aux_work = wx_ptp_do_aux_work;
507-
if (wx->mac.type == wx_mac_em) {
508-
wx->ptp_caps.max_adj = 500000000;
509+
switch (wx->mac.type) {
510+
case wx_mac_aml:
511+
case wx_mac_aml40:
512+
wx->ptp_caps.max_adj = 250000000;
509513
wx->ptp_caps.n_per_out = 1;
510514
wx->ptp_setup_sdp = wx_ptp_setup_sdp;
511515
wx->ptp_caps.enable = wx_ptp_feature_enable;
512-
} else {
516+
break;
517+
case wx_mac_sp:
513518
wx->ptp_caps.max_adj = 250000000;
514519
wx->ptp_caps.n_per_out = 0;
515520
wx->ptp_setup_sdp = NULL;
521+
break;
522+
case wx_mac_em:
523+
wx->ptp_caps.max_adj = 500000000;
524+
wx->ptp_caps.n_per_out = 1;
525+
wx->ptp_setup_sdp = wx_ptp_setup_sdp;
526+
wx->ptp_caps.enable = wx_ptp_feature_enable;
527+
break;
528+
default:
529+
return -EOPNOTSUPP;
516530
}
517531

518532
wx->ptp_clock = ptp_clock_register(&wx->ptp_caps, &wx->pdev->dev);
@@ -647,10 +661,18 @@ static u64 wx_ptp_read(const struct cyclecounter *hw_cc)
647661

648662
static void wx_ptp_link_speed_adjust(struct wx *wx, u32 *shift, u32 *incval)
649663
{
650-
if (wx->mac.type == wx_mac_em) {
664+
switch (wx->mac.type) {
665+
case wx_mac_aml:
666+
case wx_mac_aml40:
667+
*shift = WX_INCVAL_SHIFT_AML;
668+
*incval = WX_INCVAL_AML;
669+
return;
670+
case wx_mac_em:
651671
*shift = WX_INCVAL_SHIFT_EM;
652672
*incval = WX_INCVAL_EM;
653673
return;
674+
default:
675+
break;
654676
}
655677

656678
switch (wx->speed) {

0 commit comments

Comments
 (0)