1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2015 - 2022 Beijing WangXun Technology Co., Ltd. */
3
4#include <linux/types.h>
5#include <linux/module.h>
6#include <linux/pci.h>
7#include <linux/netdevice.h>
8#include <linux/string.h>
9#include <linux/etherdevice.h>
10#include <linux/phylink.h>
11#include <net/ip.h>
12#include <linux/if_vlan.h>
13
14#include "../libwx/wx_type.h"
15#include "../libwx/wx_lib.h"
16#include "../libwx/wx_hw.h"
17#include "txgbe_type.h"
18#include "txgbe_hw.h"
19#include "txgbe_phy.h"
20#include "txgbe_irq.h"
21#include "txgbe_ethtool.h"
22
23char txgbe_driver_name[] = "txgbe";
24
25/* txgbe_pci_tbl - PCI Device ID Table
26 *
27 * Wildcard entries (PCI_ANY_ID) should come last
28 * Last entry must be all 0s
29 *
30 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
31 *   Class, Class Mask, private data (not used) }
32 */
33static const struct pci_device_id txgbe_pci_tbl[] = {
34	{ PCI_VDEVICE(WANGXUN, TXGBE_DEV_ID_SP1000), 0},
35	{ PCI_VDEVICE(WANGXUN, TXGBE_DEV_ID_WX1820), 0},
36	/* required last entry */
37	{ .device = 0 }
38};
39
40#define DEFAULT_DEBUG_LEVEL_SHIFT 3
41
42static void txgbe_check_minimum_link(struct wx *wx)
43{
44	struct pci_dev *pdev;
45
46	pdev = wx->pdev;
47	pcie_print_link_status(pdev);
48}
49
50/**
51 * txgbe_enumerate_functions - Get the number of ports this device has
52 * @wx: wx structure
53 *
54 * This function enumerates the phsyical functions co-located on a single slot,
55 * in order to determine how many ports a device has. This is most useful in
56 * determining the required GT/s of PCIe bandwidth necessary for optimal
57 * performance.
58 **/
59static int txgbe_enumerate_functions(struct wx *wx)
60{
61	struct pci_dev *entry, *pdev = wx->pdev;
62	int physfns = 0;
63
64	list_for_each_entry(entry, &pdev->bus->devices, bus_list) {
65		/* When the devices on the bus don't all match our device ID,
66		 * we can't reliably determine the correct number of
67		 * functions. This can occur if a function has been direct
68		 * attached to a virtual machine using VT-d.
69		 */
70		if (entry->vendor != pdev->vendor ||
71		    entry->device != pdev->device)
72			return -EINVAL;
73
74		physfns++;
75	}
76
77	return physfns;
78}
79
80static void txgbe_up_complete(struct wx *wx)
81{
82	struct net_device *netdev = wx->netdev;
83
84	txgbe_reinit_gpio_intr(wx);
85	wx_control_hw(wx, true);
86	wx_configure_vectors(wx);
87
88	/* make sure to complete pre-operations */
89	smp_mb__before_atomic();
90	wx_napi_enable_all(wx);
91
92	phylink_start(wx->phylink);
93
94	/* clear any pending interrupts, may auto mask */
95	rd32(wx, WX_PX_IC(0));
96	rd32(wx, WX_PX_IC(1));
97	rd32(wx, WX_PX_MISC_IC);
98	txgbe_irq_enable(wx, true);
99
100	/* enable transmits */
101	netif_tx_start_all_queues(netdev);
102}
103
104static void txgbe_reset(struct wx *wx)
105{
106	struct net_device *netdev = wx->netdev;
107	u8 old_addr[ETH_ALEN];
108	int err;
109
110	err = txgbe_reset_hw(wx);
111	if (err != 0)
112		wx_err(wx, "Hardware Error: %d\n", err);
113
114	wx_start_hw(wx);
115	/* do not flush user set addresses */
116	memcpy(old_addr, &wx->mac_table[0].addr, netdev->addr_len);
117	wx_flush_sw_mac_table(wx);
118	wx_mac_set_default_filter(wx, old_addr);
119}
120
121static void txgbe_disable_device(struct wx *wx)
122{
123	struct net_device *netdev = wx->netdev;
124	u32 i;
125
126	wx_disable_pcie_master(wx);
127	/* disable receives */
128	wx_disable_rx(wx);
129
130	/* disable all enabled rx queues */
131	for (i = 0; i < wx->num_rx_queues; i++)
132		/* this call also flushes the previous write */
133		wx_disable_rx_queue(wx, wx->rx_ring[i]);
134
135	netif_tx_stop_all_queues(netdev);
136	netif_tx_disable(netdev);
137
138	wx_irq_disable(wx);
139	wx_napi_disable_all(wx);
140
141	if (wx->bus.func < 2)
142		wr32m(wx, TXGBE_MIS_PRB_CTL, TXGBE_MIS_PRB_CTL_LAN_UP(wx->bus.func), 0);
143	else
144		wx_err(wx, "%s: invalid bus lan id %d\n",
145		       __func__, wx->bus.func);
146
147	if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) ||
148	      ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) {
149		/* disable mac transmiter */
150		wr32m(wx, WX_MAC_TX_CFG, WX_MAC_TX_CFG_TE, 0);
151	}
152
153	/* disable transmits in the hardware now that interrupts are off */
154	for (i = 0; i < wx->num_tx_queues; i++) {
155		u8 reg_idx = wx->tx_ring[i]->reg_idx;
156
157		wr32(wx, WX_PX_TR_CFG(reg_idx), WX_PX_TR_CFG_SWFLSH);
158	}
159
160	/* Disable the Tx DMA engine */
161	wr32m(wx, WX_TDM_CTL, WX_TDM_CTL_TE, 0);
162
163	wx_update_stats(wx);
164}
165
166void txgbe_down(struct wx *wx)
167{
168	txgbe_disable_device(wx);
169	txgbe_reset(wx);
170	phylink_stop(wx->phylink);
171
172	wx_clean_all_tx_rings(wx);
173	wx_clean_all_rx_rings(wx);
174}
175
176void txgbe_up(struct wx *wx)
177{
178	wx_configure(wx);
179	txgbe_up_complete(wx);
180}
181
182/**
183 *  txgbe_init_type_code - Initialize the shared code
184 *  @wx: pointer to hardware structure
185 **/
186static void txgbe_init_type_code(struct wx *wx)
187{
188	u8 device_type = wx->subsystem_device_id & 0xF0;
189
190	switch (wx->device_id) {
191	case TXGBE_DEV_ID_SP1000:
192	case TXGBE_DEV_ID_WX1820:
193		wx->mac.type = wx_mac_sp;
194		break;
195	default:
196		wx->mac.type = wx_mac_unknown;
197		break;
198	}
199
200	switch (device_type) {
201	case TXGBE_ID_SFP:
202		wx->media_type = sp_media_fiber;
203		break;
204	case TXGBE_ID_XAUI:
205	case TXGBE_ID_SGMII:
206		wx->media_type = sp_media_copper;
207		break;
208	case TXGBE_ID_KR_KX_KX4:
209	case TXGBE_ID_MAC_XAUI:
210	case TXGBE_ID_MAC_SGMII:
211		wx->media_type = sp_media_backplane;
212		break;
213	case TXGBE_ID_SFI_XAUI:
214		if (wx->bus.func == 0)
215			wx->media_type = sp_media_fiber;
216		else
217			wx->media_type = sp_media_copper;
218		break;
219	default:
220		wx->media_type = sp_media_unknown;
221		break;
222	}
223}
224
225/**
226 * txgbe_sw_init - Initialize general software structures (struct wx)
227 * @wx: board private structure to initialize
228 **/
229static int txgbe_sw_init(struct wx *wx)
230{
231	u16 msix_count = 0;
232	int err;
233
234	wx->mac.num_rar_entries = TXGBE_SP_RAR_ENTRIES;
235	wx->mac.max_tx_queues = TXGBE_SP_MAX_TX_QUEUES;
236	wx->mac.max_rx_queues = TXGBE_SP_MAX_RX_QUEUES;
237	wx->mac.mcft_size = TXGBE_SP_MC_TBL_SIZE;
238	wx->mac.vft_size = TXGBE_SP_VFT_TBL_SIZE;
239	wx->mac.rx_pb_size = TXGBE_SP_RX_PB_SIZE;
240	wx->mac.tx_pb_size = TXGBE_SP_TDB_PB_SZ;
241
242	/* PCI config space info */
243	err = wx_sw_init(wx);
244	if (err < 0)
245		return err;
246
247	txgbe_init_type_code(wx);
248
249	/* Set common capability flags and settings */
250	wx->max_q_vectors = TXGBE_MAX_MSIX_VECTORS;
251	err = wx_get_pcie_msix_counts(wx, &msix_count, TXGBE_MAX_MSIX_VECTORS);
252	if (err)
253		wx_err(wx, "Do not support MSI-X\n");
254	wx->mac.max_msix_vectors = msix_count;
255
256	wx->ring_feature[RING_F_RSS].limit = min_t(int, TXGBE_MAX_RSS_INDICES,
257						   num_online_cpus());
258	wx->rss_enabled = true;
259
260	/* enable itr by default in dynamic mode */
261	wx->rx_itr_setting = 1;
262	wx->tx_itr_setting = 1;
263
264	/* set default ring sizes */
265	wx->tx_ring_count = TXGBE_DEFAULT_TXD;
266	wx->rx_ring_count = TXGBE_DEFAULT_RXD;
267
268	/* set default work limits */
269	wx->tx_work_limit = TXGBE_DEFAULT_TX_WORK;
270	wx->rx_work_limit = TXGBE_DEFAULT_RX_WORK;
271
272	return 0;
273}
274
275/**
276 * txgbe_open - Called when a network interface is made active
277 * @netdev: network interface device structure
278 *
279 * Returns 0 on success, negative value on failure
280 *
281 * The open entry point is called when a network interface is made
282 * active by the system (IFF_UP).
283 **/
284static int txgbe_open(struct net_device *netdev)
285{
286	struct wx *wx = netdev_priv(netdev);
287	int err;
288
289	err = wx_setup_resources(wx);
290	if (err)
291		goto err_reset;
292
293	wx_configure(wx);
294
295	err = txgbe_request_irq(wx);
296	if (err)
297		goto err_free_isb;
298
299	/* Notify the stack of the actual queue counts. */
300	err = netif_set_real_num_tx_queues(netdev, wx->num_tx_queues);
301	if (err)
302		goto err_free_irq;
303
304	err = netif_set_real_num_rx_queues(netdev, wx->num_rx_queues);
305	if (err)
306		goto err_free_irq;
307
308	txgbe_up_complete(wx);
309
310	return 0;
311
312err_free_irq:
313	wx_free_irq(wx);
314err_free_isb:
315	wx_free_isb_resources(wx);
316err_reset:
317	txgbe_reset(wx);
318
319	return err;
320}
321
322/**
323 * txgbe_close_suspend - actions necessary to both suspend and close flows
324 * @wx: the private wx struct
325 *
326 * This function should contain the necessary work common to both suspending
327 * and closing of the device.
328 */
329static void txgbe_close_suspend(struct wx *wx)
330{
331	txgbe_disable_device(wx);
332	wx_free_resources(wx);
333}
334
335/**
336 * txgbe_close - Disables a network interface
337 * @netdev: network interface device structure
338 *
339 * Returns 0, this is not allowed to fail
340 *
341 * The close entry point is called when an interface is de-activated
342 * by the OS.  The hardware is still under the drivers control, but
343 * needs to be disabled.  A global MAC reset is issued to stop the
344 * hardware, and all transmit and receive resources are freed.
345 **/
346static int txgbe_close(struct net_device *netdev)
347{
348	struct wx *wx = netdev_priv(netdev);
349
350	txgbe_down(wx);
351	wx_free_irq(wx);
352	wx_free_resources(wx);
353	wx_control_hw(wx, false);
354
355	return 0;
356}
357
358static void txgbe_dev_shutdown(struct pci_dev *pdev)
359{
360	struct wx *wx = pci_get_drvdata(pdev);
361	struct net_device *netdev;
362
363	netdev = wx->netdev;
364	netif_device_detach(netdev);
365
366	rtnl_lock();
367	if (netif_running(netdev))
368		txgbe_close_suspend(wx);
369	rtnl_unlock();
370
371	wx_control_hw(wx, false);
372
373	pci_disable_device(pdev);
374}
375
376static void txgbe_shutdown(struct pci_dev *pdev)
377{
378	txgbe_dev_shutdown(pdev);
379
380	if (system_state == SYSTEM_POWER_OFF) {
381		pci_wake_from_d3(pdev, false);
382		pci_set_power_state(pdev, PCI_D3hot);
383	}
384}
385
386/**
387 * txgbe_setup_tc - routine to configure net_device for multiple traffic
388 * classes.
389 *
390 * @dev: net device to configure
391 * @tc: number of traffic classes to enable
392 */
393int txgbe_setup_tc(struct net_device *dev, u8 tc)
394{
395	struct wx *wx = netdev_priv(dev);
396	struct txgbe *txgbe = wx->priv;
397
398	/* Hardware has to reinitialize queues and interrupts to
399	 * match packet buffer alignment. Unfortunately, the
400	 * hardware is not flexible enough to do this dynamically.
401	 */
402	if (netif_running(dev))
403		txgbe_close(dev);
404	else
405		txgbe_reset(wx);
406
407	txgbe_free_misc_irq(txgbe);
408	wx_clear_interrupt_scheme(wx);
409
410	if (tc)
411		netdev_set_num_tc(dev, tc);
412	else
413		netdev_reset_tc(dev);
414
415	wx_init_interrupt_scheme(wx);
416	txgbe_setup_misc_irq(txgbe);
417
418	if (netif_running(dev))
419		txgbe_open(dev);
420
421	return 0;
422}
423
424static const struct net_device_ops txgbe_netdev_ops = {
425	.ndo_open               = txgbe_open,
426	.ndo_stop               = txgbe_close,
427	.ndo_change_mtu         = wx_change_mtu,
428	.ndo_start_xmit         = wx_xmit_frame,
429	.ndo_set_rx_mode        = wx_set_rx_mode,
430	.ndo_set_features       = wx_set_features,
431	.ndo_validate_addr      = eth_validate_addr,
432	.ndo_set_mac_address    = wx_set_mac,
433	.ndo_get_stats64        = wx_get_stats64,
434	.ndo_vlan_rx_add_vid    = wx_vlan_rx_add_vid,
435	.ndo_vlan_rx_kill_vid   = wx_vlan_rx_kill_vid,
436};
437
438/**
439 * txgbe_probe - Device Initialization Routine
440 * @pdev: PCI device information struct
441 * @ent: entry in txgbe_pci_tbl
442 *
443 * Returns 0 on success, negative on failure
444 *
445 * txgbe_probe initializes an adapter identified by a pci_dev structure.
446 * The OS initialization, configuring of the wx private structure,
447 * and a hardware reset occur.
448 **/
449static int txgbe_probe(struct pci_dev *pdev,
450		       const struct pci_device_id __always_unused *ent)
451{
452	struct net_device *netdev;
453	int err, expected_gts;
454	struct wx *wx = NULL;
455	struct txgbe *txgbe;
456
457	u16 eeprom_verh = 0, eeprom_verl = 0, offset = 0;
458	u16 eeprom_cfg_blkh = 0, eeprom_cfg_blkl = 0;
459	u16 build = 0, major = 0, patch = 0;
460	u32 etrack_id = 0;
461
462	err = pci_enable_device_mem(pdev);
463	if (err)
464		return err;
465
466	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
467	if (err) {
468		dev_err(&pdev->dev,
469			"No usable DMA configuration, aborting\n");
470		goto err_pci_disable_dev;
471	}
472
473	err = pci_request_selected_regions(pdev,
474					   pci_select_bars(pdev, IORESOURCE_MEM),
475					   txgbe_driver_name);
476	if (err) {
477		dev_err(&pdev->dev,
478			"pci_request_selected_regions failed 0x%x\n", err);
479		goto err_pci_disable_dev;
480	}
481
482	pci_set_master(pdev);
483
484	netdev = devm_alloc_etherdev_mqs(&pdev->dev,
485					 sizeof(struct wx),
486					 TXGBE_MAX_TX_QUEUES,
487					 TXGBE_MAX_RX_QUEUES);
488	if (!netdev) {
489		err = -ENOMEM;
490		goto err_pci_release_regions;
491	}
492
493	SET_NETDEV_DEV(netdev, &pdev->dev);
494
495	wx = netdev_priv(netdev);
496	wx->netdev = netdev;
497	wx->pdev = pdev;
498
499	wx->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
500
501	wx->hw_addr = devm_ioremap(&pdev->dev,
502				   pci_resource_start(pdev, 0),
503				   pci_resource_len(pdev, 0));
504	if (!wx->hw_addr) {
505		err = -EIO;
506		goto err_pci_release_regions;
507	}
508
509	wx->driver_name = txgbe_driver_name;
510	txgbe_set_ethtool_ops(netdev);
511	netdev->netdev_ops = &txgbe_netdev_ops;
512
513	/* setup the private structure */
514	err = txgbe_sw_init(wx);
515	if (err)
516		goto err_free_mac_table;
517
518	/* check if flash load is done after hw power up */
519	err = wx_check_flash_load(wx, TXGBE_SPI_ILDR_STATUS_PERST);
520	if (err)
521		goto err_free_mac_table;
522	err = wx_check_flash_load(wx, TXGBE_SPI_ILDR_STATUS_PWRRST);
523	if (err)
524		goto err_free_mac_table;
525
526	err = wx_mng_present(wx);
527	if (err) {
528		dev_err(&pdev->dev, "Management capability is not present\n");
529		goto err_free_mac_table;
530	}
531
532	err = txgbe_reset_hw(wx);
533	if (err) {
534		dev_err(&pdev->dev, "HW Init failed: %d\n", err);
535		goto err_free_mac_table;
536	}
537
538	netdev->features = NETIF_F_SG |
539			   NETIF_F_TSO |
540			   NETIF_F_TSO6 |
541			   NETIF_F_RXHASH |
542			   NETIF_F_RXCSUM |
543			   NETIF_F_HW_CSUM;
544
545	netdev->gso_partial_features =  NETIF_F_GSO_ENCAP_ALL;
546	netdev->features |= netdev->gso_partial_features;
547	netdev->features |= NETIF_F_SCTP_CRC;
548	netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID;
549	netdev->hw_enc_features |= netdev->vlan_features;
550	netdev->features |= NETIF_F_VLAN_FEATURES;
551	/* copy netdev features into list of user selectable features */
552	netdev->hw_features |= netdev->features | NETIF_F_RXALL;
553	netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC;
554	netdev->features |= NETIF_F_HIGHDMA;
555	netdev->hw_features |= NETIF_F_GRO;
556	netdev->features |= NETIF_F_GRO;
557
558	netdev->priv_flags |= IFF_UNICAST_FLT;
559	netdev->priv_flags |= IFF_SUPP_NOFCS;
560	netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
561
562	netdev->min_mtu = ETH_MIN_MTU;
563	netdev->max_mtu = WX_MAX_JUMBO_FRAME_SIZE -
564			  (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
565
566	/* make sure the EEPROM is good */
567	err = txgbe_validate_eeprom_checksum(wx, NULL);
568	if (err != 0) {
569		dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n");
570		wr32(wx, WX_MIS_RST, WX_MIS_RST_SW_RST);
571		err = -EIO;
572		goto err_free_mac_table;
573	}
574
575	eth_hw_addr_set(netdev, wx->mac.perm_addr);
576	wx_mac_set_default_filter(wx, wx->mac.perm_addr);
577
578	err = wx_init_interrupt_scheme(wx);
579	if (err)
580		goto err_free_mac_table;
581
582	/* Save off EEPROM version number and Option Rom version which
583	 * together make a unique identify for the eeprom
584	 */
585	wx_read_ee_hostif(wx,
586			  wx->eeprom.sw_region_offset + TXGBE_EEPROM_VERSION_H,
587			  &eeprom_verh);
588	wx_read_ee_hostif(wx,
589			  wx->eeprom.sw_region_offset + TXGBE_EEPROM_VERSION_L,
590			  &eeprom_verl);
591	etrack_id = (eeprom_verh << 16) | eeprom_verl;
592
593	wx_read_ee_hostif(wx,
594			  wx->eeprom.sw_region_offset + TXGBE_ISCSI_BOOT_CONFIG,
595			  &offset);
596
597	/* Make sure offset to SCSI block is valid */
598	if (!(offset == 0x0) && !(offset == 0xffff)) {
599		wx_read_ee_hostif(wx, offset + 0x84, &eeprom_cfg_blkh);
600		wx_read_ee_hostif(wx, offset + 0x83, &eeprom_cfg_blkl);
601
602		/* Only display Option Rom if exist */
603		if (eeprom_cfg_blkl && eeprom_cfg_blkh) {
604			major = eeprom_cfg_blkl >> 8;
605			build = (eeprom_cfg_blkl << 8) | (eeprom_cfg_blkh >> 8);
606			patch = eeprom_cfg_blkh & 0x00ff;
607
608			snprintf(wx->eeprom_id, sizeof(wx->eeprom_id),
609				 "0x%08x, %d.%d.%d", etrack_id, major, build,
610				 patch);
611		} else {
612			snprintf(wx->eeprom_id, sizeof(wx->eeprom_id),
613				 "0x%08x", etrack_id);
614		}
615	} else {
616		snprintf(wx->eeprom_id, sizeof(wx->eeprom_id),
617			 "0x%08x", etrack_id);
618	}
619
620	if (etrack_id < 0x20010)
621		dev_warn(&pdev->dev, "Please upgrade the firmware to 0x20010 or above.\n");
622
623	txgbe = devm_kzalloc(&pdev->dev, sizeof(*txgbe), GFP_KERNEL);
624	if (!txgbe) {
625		err = -ENOMEM;
626		goto err_release_hw;
627	}
628
629	txgbe->wx = wx;
630	wx->priv = txgbe;
631
632	err = txgbe_setup_misc_irq(txgbe);
633	if (err)
634		goto err_release_hw;
635
636	err = txgbe_init_phy(txgbe);
637	if (err)
638		goto err_free_misc_irq;
639
640	err = register_netdev(netdev);
641	if (err)
642		goto err_remove_phy;
643
644	pci_set_drvdata(pdev, wx);
645
646	netif_tx_stop_all_queues(netdev);
647
648	/* calculate the expected PCIe bandwidth required for optimal
649	 * performance. Note that some older parts will never have enough
650	 * bandwidth due to being older generation PCIe parts. We clamp these
651	 * parts to ensure that no warning is displayed, as this could confuse
652	 * users otherwise.
653	 */
654	expected_gts = txgbe_enumerate_functions(wx) * 10;
655
656	/* don't check link if we failed to enumerate functions */
657	if (expected_gts > 0)
658		txgbe_check_minimum_link(wx);
659	else
660		dev_warn(&pdev->dev, "Failed to enumerate PF devices.\n");
661
662	return 0;
663
664err_remove_phy:
665	txgbe_remove_phy(txgbe);
666err_free_misc_irq:
667	txgbe_free_misc_irq(txgbe);
668err_release_hw:
669	wx_clear_interrupt_scheme(wx);
670	wx_control_hw(wx, false);
671err_free_mac_table:
672	kfree(wx->mac_table);
673err_pci_release_regions:
674	pci_release_selected_regions(pdev,
675				     pci_select_bars(pdev, IORESOURCE_MEM));
676err_pci_disable_dev:
677	pci_disable_device(pdev);
678	return err;
679}
680
681/**
682 * txgbe_remove - Device Removal Routine
683 * @pdev: PCI device information struct
684 *
685 * txgbe_remove is called by the PCI subsystem to alert the driver
686 * that it should release a PCI device.  The could be caused by a
687 * Hot-Plug event, or because the driver is going to be removed from
688 * memory.
689 **/
690static void txgbe_remove(struct pci_dev *pdev)
691{
692	struct wx *wx = pci_get_drvdata(pdev);
693	struct txgbe *txgbe = wx->priv;
694	struct net_device *netdev;
695
696	netdev = wx->netdev;
697	unregister_netdev(netdev);
698
699	txgbe_remove_phy(txgbe);
700	txgbe_free_misc_irq(txgbe);
701
702	pci_release_selected_regions(pdev,
703				     pci_select_bars(pdev, IORESOURCE_MEM));
704
705	kfree(wx->rss_key);
706	kfree(wx->mac_table);
707	wx_clear_interrupt_scheme(wx);
708
709	pci_disable_device(pdev);
710}
711
712static struct pci_driver txgbe_driver = {
713	.name     = txgbe_driver_name,
714	.id_table = txgbe_pci_tbl,
715	.probe    = txgbe_probe,
716	.remove   = txgbe_remove,
717	.shutdown = txgbe_shutdown,
718};
719
720module_pci_driver(txgbe_driver);
721
722MODULE_DEVICE_TABLE(pci, txgbe_pci_tbl);
723MODULE_AUTHOR("Beijing WangXun Technology Co., Ltd, <software@trustnetic.com>");
724MODULE_DESCRIPTION("WangXun(R) 10 Gigabit PCI Express Network Driver");
725MODULE_LICENSE("GPL");
726