Skip to content

Commit 0ef7e15

Browse files
Jiawen Wudavem330
authored andcommitted
net: txgbe: Setup Rx and Tx ring
Improve the configuration of Rx and Tx ring, set Rx flags and implement ndo_set_rx_mode ops. Signed-off-by: Jiawen Wu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 850b971 commit 0ef7e15

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
#define WX_MAC_TX_CFG 0x11000
201201
#define WX_MAC_TX_CFG_TE BIT(0)
202202
#define WX_MAC_TX_CFG_SPEED_MASK GENMASK(30, 29)
203+
#define WX_MAC_TX_CFG_SPEED_10G FIELD_PREP(WX_MAC_TX_CFG_SPEED_MASK, 0)
203204
#define WX_MAC_TX_CFG_SPEED_1G FIELD_PREP(WX_MAC_TX_CFG_SPEED_MASK, 3)
204205
#define WX_MAC_RX_CFG 0x11004
205206
#define WX_MAC_RX_CFG_RE BIT(0)

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

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,24 @@ static int txgbe_request_irq(struct wx *wx)
218218

219219
static void txgbe_up_complete(struct wx *wx)
220220
{
221+
u32 reg;
222+
221223
wx_control_hw(wx, true);
222224
wx_configure_vectors(wx);
223225

224226
/* clear any pending interrupts, may auto mask */
225227
rd32(wx, WX_PX_IC);
226228
rd32(wx, WX_PX_MISC_IC);
227229
txgbe_irq_enable(wx, true);
230+
231+
/* Configure MAC Rx and Tx when link is up */
232+
reg = rd32(wx, WX_MAC_RX_CFG);
233+
wr32(wx, WX_MAC_RX_CFG, reg);
234+
wr32(wx, WX_MAC_PKT_FLT, WX_MAC_PKT_FLT_PR);
235+
reg = rd32(wx, WX_MAC_WDG_TIMEOUT);
236+
wr32(wx, WX_MAC_WDG_TIMEOUT, reg);
237+
reg = rd32(wx, WX_MAC_TX_CFG);
238+
wr32(wx, WX_MAC_TX_CFG, (reg & ~WX_MAC_TX_CFG_SPEED_MASK) | WX_MAC_TX_CFG_SPEED_10G);
228239
}
229240

230241
static void txgbe_reset(struct wx *wx)
@@ -246,11 +257,17 @@ static void txgbe_reset(struct wx *wx)
246257
static void txgbe_disable_device(struct wx *wx)
247258
{
248259
struct net_device *netdev = wx->netdev;
260+
u32 i;
249261

250262
wx_disable_pcie_master(wx);
251263
/* disable receives */
252264
wx_disable_rx(wx);
253265

266+
/* disable all enabled rx queues */
267+
for (i = 0; i < wx->num_rx_queues; i++)
268+
/* this call also flushes the previous write */
269+
wx_disable_rx_queue(wx, wx->rx_ring[i]);
270+
254271
netif_carrier_off(netdev);
255272
netif_tx_disable(netdev);
256273

@@ -268,6 +285,13 @@ static void txgbe_disable_device(struct wx *wx)
268285
wr32m(wx, WX_MAC_TX_CFG, WX_MAC_TX_CFG_TE, 0);
269286
}
270287

288+
/* disable transmits in the hardware now that interrupts are off */
289+
for (i = 0; i < wx->num_tx_queues; i++) {
290+
u8 reg_idx = wx->tx_ring[i]->reg_idx;
291+
292+
wr32(wx, WX_PX_TR_CFG(reg_idx), WX_PX_TR_CFG_SWFLSH);
293+
}
294+
271295
/* Disable the Tx DMA engine */
272296
wr32m(wx, WX_TDM_CTL, WX_TDM_CTL_TE, 0);
273297
}
@@ -291,6 +315,8 @@ static int txgbe_sw_init(struct wx *wx)
291315
wx->mac.max_tx_queues = TXGBE_SP_MAX_TX_QUEUES;
292316
wx->mac.max_rx_queues = TXGBE_SP_MAX_RX_QUEUES;
293317
wx->mac.mcft_size = TXGBE_SP_MC_TBL_SIZE;
318+
wx->mac.rx_pb_size = TXGBE_SP_RX_PB_SIZE;
319+
wx->mac.tx_pb_size = TXGBE_SP_TDB_PB_SZ;
294320

295321
/* PCI config space info */
296322
err = wx_sw_init(wx);
@@ -345,7 +371,7 @@ static int txgbe_open(struct net_device *netdev)
345371
struct wx *wx = netdev_priv(netdev);
346372
int err;
347373

348-
err = wx_setup_isb_resources(wx);
374+
err = wx_setup_resources(wx);
349375
if (err)
350376
goto err_reset;
351377

@@ -379,7 +405,7 @@ static void txgbe_close_suspend(struct wx *wx)
379405
txgbe_disable_device(wx);
380406

381407
wx_free_irq(wx);
382-
wx_free_isb_resources(wx);
408+
wx_free_resources(wx);
383409
}
384410

385411
/**
@@ -399,7 +425,7 @@ static int txgbe_close(struct net_device *netdev)
399425

400426
txgbe_down(wx);
401427
wx_free_irq(wx);
402-
wx_free_isb_resources(wx);
428+
wx_free_resources(wx);
403429
wx_control_hw(wx, false);
404430

405431
return 0;
@@ -445,6 +471,7 @@ static const struct net_device_ops txgbe_netdev_ops = {
445471
.ndo_open = txgbe_open,
446472
.ndo_stop = txgbe_close,
447473
.ndo_start_xmit = txgbe_xmit_frame,
474+
.ndo_set_rx_mode = wx_set_rx_mode,
448475
.ndo_validate_addr = eth_validate_addr,
449476
.ndo_set_mac_address = wx_set_mac,
450477
};
@@ -549,6 +576,16 @@ static int txgbe_probe(struct pci_dev *pdev,
549576
}
550577

551578
netdev->features |= NETIF_F_HIGHDMA;
579+
netdev->features = NETIF_F_SG;
580+
581+
/* copy netdev features into list of user selectable features */
582+
netdev->hw_features |= netdev->features | NETIF_F_RXALL;
583+
584+
netdev->priv_flags |= IFF_UNICAST_FLT;
585+
netdev->priv_flags |= IFF_SUPP_NOFCS;
586+
587+
netdev->min_mtu = ETH_MIN_MTU;
588+
netdev->max_mtu = TXGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN);
552589

553590
/* make sure the EEPROM is good */
554591
err = txgbe_validate_eeprom_checksum(wx, NULL);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
#define TXGBE_SP_MAX_RX_QUEUES 128
7878
#define TXGBE_SP_RAR_ENTRIES 128
7979
#define TXGBE_SP_MC_TBL_SIZE 128
80+
#define TXGBE_SP_RX_PB_SIZE 512
81+
#define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */
82+
#define TXGBE_MAX_JUMBO_FRAME_SIZE 9432 /* max payload 9414 */
8083

8184
/* TX/RX descriptor defines */
8285
#define TXGBE_DEFAULT_TXD 512

0 commit comments

Comments
 (0)