igc_main.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright (c) 2018 Intel Corporation */
  3. #include <linux/module.h>
  4. #include <linux/types.h>
  5. #include <linux/if_vlan.h>
  6. #include <linux/aer.h>
  7. #include "igc.h"
  8. #include "igc_hw.h"
  9. #define DRV_VERSION "0.0.1-k"
  10. #define DRV_SUMMARY "Intel(R) 2.5G Ethernet Linux Driver"
  11. static int debug = -1;
  12. MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
  13. MODULE_DESCRIPTION(DRV_SUMMARY);
  14. MODULE_LICENSE("GPL v2");
  15. MODULE_VERSION(DRV_VERSION);
  16. module_param(debug, int, 0);
  17. MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
  18. char igc_driver_name[] = "igc";
  19. char igc_driver_version[] = DRV_VERSION;
  20. static const char igc_driver_string[] = DRV_SUMMARY;
  21. static const char igc_copyright[] =
  22. "Copyright(c) 2018 Intel Corporation.";
  23. static const struct pci_device_id igc_pci_tbl[] = {
  24. { PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_LM) },
  25. { PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_V) },
  26. /* required last entry */
  27. {0, }
  28. };
  29. MODULE_DEVICE_TABLE(pci, igc_pci_tbl);
  30. /* forward declaration */
  31. static int igc_sw_init(struct igc_adapter *);
  32. static void igc_configure(struct igc_adapter *adapter);
  33. static void igc_power_down_link(struct igc_adapter *adapter);
  34. static void igc_set_default_mac_filter(struct igc_adapter *adapter);
  35. static void igc_reset(struct igc_adapter *adapter)
  36. {
  37. if (!netif_running(adapter->netdev))
  38. igc_power_down_link(adapter);
  39. }
  40. /**
  41. * igc_power_up_link - Power up the phy/serdes link
  42. * @adapter: address of board private structure
  43. */
  44. static void igc_power_up_link(struct igc_adapter *adapter)
  45. {
  46. }
  47. /**
  48. * igc_power_down_link - Power down the phy/serdes link
  49. * @adapter: address of board private structure
  50. */
  51. static void igc_power_down_link(struct igc_adapter *adapter)
  52. {
  53. }
  54. /**
  55. * igc_release_hw_control - release control of the h/w to f/w
  56. * @adapter: address of board private structure
  57. *
  58. * igc_release_hw_control resets CTRL_EXT:DRV_LOAD bit.
  59. * For ASF and Pass Through versions of f/w this means that the
  60. * driver is no longer loaded.
  61. */
  62. static void igc_release_hw_control(struct igc_adapter *adapter)
  63. {
  64. struct igc_hw *hw = &adapter->hw;
  65. u32 ctrl_ext;
  66. /* Let firmware take over control of h/w */
  67. ctrl_ext = rd32(IGC_CTRL_EXT);
  68. wr32(IGC_CTRL_EXT,
  69. ctrl_ext & ~IGC_CTRL_EXT_DRV_LOAD);
  70. }
  71. /**
  72. * igc_get_hw_control - get control of the h/w from f/w
  73. * @adapter: address of board private structure
  74. *
  75. * igc_get_hw_control sets CTRL_EXT:DRV_LOAD bit.
  76. * For ASF and Pass Through versions of f/w this means that
  77. * the driver is loaded.
  78. */
  79. static void igc_get_hw_control(struct igc_adapter *adapter)
  80. {
  81. struct igc_hw *hw = &adapter->hw;
  82. u32 ctrl_ext;
  83. /* Let firmware know the driver has taken over */
  84. ctrl_ext = rd32(IGC_CTRL_EXT);
  85. wr32(IGC_CTRL_EXT,
  86. ctrl_ext | IGC_CTRL_EXT_DRV_LOAD);
  87. }
  88. /**
  89. * igc_set_mac - Change the Ethernet Address of the NIC
  90. * @netdev: network interface device structure
  91. * @p: pointer to an address structure
  92. *
  93. * Returns 0 on success, negative on failure
  94. */
  95. static int igc_set_mac(struct net_device *netdev, void *p)
  96. {
  97. struct igc_adapter *adapter = netdev_priv(netdev);
  98. struct igc_hw *hw = &adapter->hw;
  99. struct sockaddr *addr = p;
  100. if (!is_valid_ether_addr(addr->sa_data))
  101. return -EADDRNOTAVAIL;
  102. memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
  103. memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);
  104. /* set the correct pool for the new PF MAC address in entry 0 */
  105. igc_set_default_mac_filter(adapter);
  106. return 0;
  107. }
  108. static netdev_tx_t igc_xmit_frame(struct sk_buff *skb,
  109. struct net_device *netdev)
  110. {
  111. dev_kfree_skb_any(skb);
  112. return NETDEV_TX_OK;
  113. }
  114. /**
  115. * igc_ioctl - I/O control method
  116. * @netdev: network interface device structure
  117. * @ifreq: frequency
  118. * @cmd: command
  119. */
  120. static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
  121. {
  122. switch (cmd) {
  123. default:
  124. return -EOPNOTSUPP;
  125. }
  126. }
  127. /**
  128. * igc_up - Open the interface and prepare it to handle traffic
  129. * @adapter: board private structure
  130. */
  131. static void igc_up(struct igc_adapter *adapter)
  132. {
  133. int i = 0;
  134. /* hardware has been reset, we need to reload some things */
  135. igc_configure(adapter);
  136. clear_bit(__IGC_DOWN, &adapter->state);
  137. for (i = 0; i < adapter->num_q_vectors; i++)
  138. napi_enable(&adapter->q_vector[i]->napi);
  139. }
  140. /**
  141. * igc_update_stats - Update the board statistics counters
  142. * @adapter: board private structure
  143. */
  144. static void igc_update_stats(struct igc_adapter *adapter)
  145. {
  146. }
  147. /**
  148. * igc_down - Close the interface
  149. * @adapter: board private structure
  150. */
  151. static void igc_down(struct igc_adapter *adapter)
  152. {
  153. struct net_device *netdev = adapter->netdev;
  154. int i = 0;
  155. set_bit(__IGC_DOWN, &adapter->state);
  156. /* set trans_start so we don't get spurious watchdogs during reset */
  157. netif_trans_update(netdev);
  158. netif_carrier_off(netdev);
  159. netif_tx_stop_all_queues(netdev);
  160. for (i = 0; i < adapter->num_q_vectors; i++)
  161. napi_disable(&adapter->q_vector[i]->napi);
  162. adapter->link_speed = 0;
  163. adapter->link_duplex = 0;
  164. }
  165. /**
  166. * igc_change_mtu - Change the Maximum Transfer Unit
  167. * @netdev: network interface device structure
  168. * @new_mtu: new value for maximum frame size
  169. *
  170. * Returns 0 on success, negative on failure
  171. */
  172. static int igc_change_mtu(struct net_device *netdev, int new_mtu)
  173. {
  174. int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
  175. struct igc_adapter *adapter = netdev_priv(netdev);
  176. struct pci_dev *pdev = adapter->pdev;
  177. /* adjust max frame to be at least the size of a standard frame */
  178. if (max_frame < (ETH_FRAME_LEN + ETH_FCS_LEN))
  179. max_frame = ETH_FRAME_LEN + ETH_FCS_LEN;
  180. while (test_and_set_bit(__IGC_RESETTING, &adapter->state))
  181. usleep_range(1000, 2000);
  182. /* igc_down has a dependency on max_frame_size */
  183. adapter->max_frame_size = max_frame;
  184. if (netif_running(netdev))
  185. igc_down(adapter);
  186. dev_info(&pdev->dev, "changing MTU from %d to %d\n",
  187. netdev->mtu, new_mtu);
  188. netdev->mtu = new_mtu;
  189. if (netif_running(netdev))
  190. igc_up(adapter);
  191. else
  192. igc_reset(adapter);
  193. clear_bit(__IGC_RESETTING, &adapter->state);
  194. return 0;
  195. }
  196. /**
  197. * igc_get_stats - Get System Network Statistics
  198. * @netdev: network interface device structure
  199. *
  200. * Returns the address of the device statistics structure.
  201. * The statistics are updated here and also from the timer callback.
  202. */
  203. static struct net_device_stats *igc_get_stats(struct net_device *netdev)
  204. {
  205. struct igc_adapter *adapter = netdev_priv(netdev);
  206. if (!test_bit(__IGC_RESETTING, &adapter->state))
  207. igc_update_stats(adapter);
  208. /* only return the current stats */
  209. return &netdev->stats;
  210. }
  211. /**
  212. * igc_configure - configure the hardware for RX and TX
  213. * @adapter: private board structure
  214. */
  215. static void igc_configure(struct igc_adapter *adapter)
  216. {
  217. igc_get_hw_control(adapter);
  218. }
  219. /**
  220. * igc_rar_set_index - Sync RAL[index] and RAH[index] registers with MAC table
  221. * @adapter: Pointer to adapter structure
  222. * @index: Index of the RAR entry which need to be synced with MAC table
  223. */
  224. static void igc_rar_set_index(struct igc_adapter *adapter, u32 index)
  225. {
  226. u8 *addr = adapter->mac_table[index].addr;
  227. struct igc_hw *hw = &adapter->hw;
  228. u32 rar_low, rar_high;
  229. /* HW expects these to be in network order when they are plugged
  230. * into the registers which are little endian. In order to guarantee
  231. * that ordering we need to do an leXX_to_cpup here in order to be
  232. * ready for the byteswap that occurs with writel
  233. */
  234. rar_low = le32_to_cpup((__le32 *)(addr));
  235. rar_high = le16_to_cpup((__le16 *)(addr + 4));
  236. /* Indicate to hardware the Address is Valid. */
  237. if (adapter->mac_table[index].state & IGC_MAC_STATE_IN_USE) {
  238. if (is_valid_ether_addr(addr))
  239. rar_high |= IGC_RAH_AV;
  240. rar_high |= IGC_RAH_POOL_1 <<
  241. adapter->mac_table[index].queue;
  242. }
  243. wr32(IGC_RAL(index), rar_low);
  244. wrfl();
  245. wr32(IGC_RAH(index), rar_high);
  246. wrfl();
  247. }
  248. /* Set default MAC address for the PF in the first RAR entry */
  249. static void igc_set_default_mac_filter(struct igc_adapter *adapter)
  250. {
  251. struct igc_mac_addr *mac_table = &adapter->mac_table[0];
  252. ether_addr_copy(mac_table->addr, adapter->hw.mac.addr);
  253. mac_table->state = IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;
  254. igc_rar_set_index(adapter, 0);
  255. }
  256. /**
  257. * igc_open - Called when a network interface is made active
  258. * @netdev: network interface device structure
  259. *
  260. * Returns 0 on success, negative value on failure
  261. *
  262. * The open entry point is called when a network interface is made
  263. * active by the system (IFF_UP). At this point all resources needed
  264. * for transmit and receive operations are allocated, the interrupt
  265. * handler is registered with the OS, the watchdog timer is started,
  266. * and the stack is notified that the interface is ready.
  267. */
  268. static int __igc_open(struct net_device *netdev, bool resuming)
  269. {
  270. struct igc_adapter *adapter = netdev_priv(netdev);
  271. struct igc_hw *hw = &adapter->hw;
  272. int i = 0;
  273. /* disallow open during test */
  274. if (test_bit(__IGC_TESTING, &adapter->state)) {
  275. WARN_ON(resuming);
  276. return -EBUSY;
  277. }
  278. netif_carrier_off(netdev);
  279. igc_power_up_link(adapter);
  280. igc_configure(adapter);
  281. clear_bit(__IGC_DOWN, &adapter->state);
  282. for (i = 0; i < adapter->num_q_vectors; i++)
  283. napi_enable(&adapter->q_vector[i]->napi);
  284. /* start the watchdog. */
  285. hw->mac.get_link_status = 1;
  286. return IGC_SUCCESS;
  287. }
  288. static int igc_open(struct net_device *netdev)
  289. {
  290. return __igc_open(netdev, false);
  291. }
  292. /**
  293. * igc_close - Disables a network interface
  294. * @netdev: network interface device structure
  295. *
  296. * Returns 0, this is not allowed to fail
  297. *
  298. * The close entry point is called when an interface is de-activated
  299. * by the OS. The hardware is still under the driver's control, but
  300. * needs to be disabled. A global MAC reset is issued to stop the
  301. * hardware, and all transmit and receive resources are freed.
  302. */
  303. static int __igc_close(struct net_device *netdev, bool suspending)
  304. {
  305. struct igc_adapter *adapter = netdev_priv(netdev);
  306. WARN_ON(test_bit(__IGC_RESETTING, &adapter->state));
  307. igc_down(adapter);
  308. igc_release_hw_control(adapter);
  309. return 0;
  310. }
  311. static int igc_close(struct net_device *netdev)
  312. {
  313. if (netif_device_present(netdev) || netdev->dismantle)
  314. return __igc_close(netdev, false);
  315. return 0;
  316. }
  317. static const struct net_device_ops igc_netdev_ops = {
  318. .ndo_open = igc_open,
  319. .ndo_stop = igc_close,
  320. .ndo_start_xmit = igc_xmit_frame,
  321. .ndo_set_mac_address = igc_set_mac,
  322. .ndo_change_mtu = igc_change_mtu,
  323. .ndo_get_stats = igc_get_stats,
  324. .ndo_do_ioctl = igc_ioctl,
  325. };
  326. /* PCIe configuration access */
  327. void igc_read_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value)
  328. {
  329. struct igc_adapter *adapter = hw->back;
  330. pci_read_config_word(adapter->pdev, reg, value);
  331. }
  332. void igc_write_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value)
  333. {
  334. struct igc_adapter *adapter = hw->back;
  335. pci_write_config_word(adapter->pdev, reg, *value);
  336. }
  337. s32 igc_read_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value)
  338. {
  339. struct igc_adapter *adapter = hw->back;
  340. u16 cap_offset;
  341. cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
  342. if (!cap_offset)
  343. return -IGC_ERR_CONFIG;
  344. pci_read_config_word(adapter->pdev, cap_offset + reg, value);
  345. return IGC_SUCCESS;
  346. }
  347. s32 igc_write_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value)
  348. {
  349. struct igc_adapter *adapter = hw->back;
  350. u16 cap_offset;
  351. cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
  352. if (!cap_offset)
  353. return -IGC_ERR_CONFIG;
  354. pci_write_config_word(adapter->pdev, cap_offset + reg, *value);
  355. return IGC_SUCCESS;
  356. }
  357. u32 igc_rd32(struct igc_hw *hw, u32 reg)
  358. {
  359. struct igc_adapter *igc = container_of(hw, struct igc_adapter, hw);
  360. u8 __iomem *hw_addr = READ_ONCE(hw->hw_addr);
  361. u32 value = 0;
  362. if (IGC_REMOVED(hw_addr))
  363. return ~value;
  364. value = readl(&hw_addr[reg]);
  365. /* reads should not return all F's */
  366. if (!(~value) && (!reg || !(~readl(hw_addr)))) {
  367. struct net_device *netdev = igc->netdev;
  368. hw->hw_addr = NULL;
  369. netif_device_detach(netdev);
  370. netdev_err(netdev, "PCIe link lost, device now detached\n");
  371. }
  372. return value;
  373. }
  374. /**
  375. * igc_probe - Device Initialization Routine
  376. * @pdev: PCI device information struct
  377. * @ent: entry in igc_pci_tbl
  378. *
  379. * Returns 0 on success, negative on failure
  380. *
  381. * igc_probe initializes an adapter identified by a pci_dev structure.
  382. * The OS initialization, configuring the adapter private structure,
  383. * and a hardware reset occur.
  384. */
  385. static int igc_probe(struct pci_dev *pdev,
  386. const struct pci_device_id *ent)
  387. {
  388. struct igc_adapter *adapter;
  389. struct net_device *netdev;
  390. struct igc_hw *hw;
  391. int err, pci_using_dac;
  392. err = pci_enable_device_mem(pdev);
  393. if (err)
  394. return err;
  395. pci_using_dac = 0;
  396. err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
  397. if (!err) {
  398. err = dma_set_coherent_mask(&pdev->dev,
  399. DMA_BIT_MASK(64));
  400. if (!err)
  401. pci_using_dac = 1;
  402. } else {
  403. err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
  404. if (err) {
  405. err = dma_set_coherent_mask(&pdev->dev,
  406. DMA_BIT_MASK(32));
  407. if (err) {
  408. IGC_ERR("Wrong DMA configuration, aborting\n");
  409. goto err_dma;
  410. }
  411. }
  412. }
  413. err = pci_request_selected_regions(pdev,
  414. pci_select_bars(pdev,
  415. IORESOURCE_MEM),
  416. igc_driver_name);
  417. if (err)
  418. goto err_pci_reg;
  419. pci_enable_pcie_error_reporting(pdev);
  420. pci_set_master(pdev);
  421. err = -ENOMEM;
  422. netdev = alloc_etherdev_mq(sizeof(struct igc_adapter),
  423. IGC_MAX_TX_QUEUES);
  424. if (!netdev)
  425. goto err_alloc_etherdev;
  426. SET_NETDEV_DEV(netdev, &pdev->dev);
  427. pci_set_drvdata(pdev, netdev);
  428. adapter = netdev_priv(netdev);
  429. adapter->netdev = netdev;
  430. adapter->pdev = pdev;
  431. hw = &adapter->hw;
  432. hw->back = adapter;
  433. adapter->port_num = hw->bus.func;
  434. adapter->msg_enable = GENMASK(debug - 1, 0);
  435. err = pci_save_state(pdev);
  436. if (err)
  437. goto err_ioremap;
  438. err = -EIO;
  439. adapter->io_addr = ioremap(pci_resource_start(pdev, 0),
  440. pci_resource_len(pdev, 0));
  441. if (!adapter->io_addr)
  442. goto err_ioremap;
  443. /* hw->hw_addr can be zeroed, so use adapter->io_addr for unmap */
  444. hw->hw_addr = adapter->io_addr;
  445. netdev->netdev_ops = &igc_netdev_ops;
  446. netdev->watchdog_timeo = 5 * HZ;
  447. netdev->mem_start = pci_resource_start(pdev, 0);
  448. netdev->mem_end = pci_resource_end(pdev, 0);
  449. /* PCI config space info */
  450. hw->vendor_id = pdev->vendor;
  451. hw->device_id = pdev->device;
  452. hw->revision_id = pdev->revision;
  453. hw->subsystem_vendor_id = pdev->subsystem_vendor;
  454. hw->subsystem_device_id = pdev->subsystem_device;
  455. /* setup the private structure */
  456. err = igc_sw_init(adapter);
  457. if (err)
  458. goto err_sw_init;
  459. /* MTU range: 68 - 9216 */
  460. netdev->min_mtu = ETH_MIN_MTU;
  461. netdev->max_mtu = MAX_STD_JUMBO_FRAME_SIZE;
  462. /* reset the hardware with the new settings */
  463. igc_reset(adapter);
  464. /* let the f/w know that the h/w is now under the control of the
  465. * driver.
  466. */
  467. igc_get_hw_control(adapter);
  468. strncpy(netdev->name, "eth%d", IFNAMSIZ);
  469. err = register_netdev(netdev);
  470. if (err)
  471. goto err_register;
  472. /* carrier off reporting is important to ethtool even BEFORE open */
  473. netif_carrier_off(netdev);
  474. /* print pcie link status and MAC address */
  475. pcie_print_link_status(pdev);
  476. netdev_info(netdev, "MAC: %pM\n", netdev->dev_addr);
  477. return 0;
  478. err_register:
  479. igc_release_hw_control(adapter);
  480. err_sw_init:
  481. err_ioremap:
  482. free_netdev(netdev);
  483. err_alloc_etherdev:
  484. pci_release_selected_regions(pdev,
  485. pci_select_bars(pdev, IORESOURCE_MEM));
  486. err_pci_reg:
  487. err_dma:
  488. pci_disable_device(pdev);
  489. return err;
  490. }
  491. /**
  492. * igc_remove - Device Removal Routine
  493. * @pdev: PCI device information struct
  494. *
  495. * igc_remove is called by the PCI subsystem to alert the driver
  496. * that it should release a PCI device. This could be caused by a
  497. * Hot-Plug event, or because the driver is going to be removed from
  498. * memory.
  499. */
  500. static void igc_remove(struct pci_dev *pdev)
  501. {
  502. struct net_device *netdev = pci_get_drvdata(pdev);
  503. struct igc_adapter *adapter = netdev_priv(netdev);
  504. set_bit(__IGC_DOWN, &adapter->state);
  505. flush_scheduled_work();
  506. /* Release control of h/w to f/w. If f/w is AMT enabled, this
  507. * would have already happened in close and is redundant.
  508. */
  509. igc_release_hw_control(adapter);
  510. unregister_netdev(netdev);
  511. pci_release_selected_regions(pdev,
  512. pci_select_bars(pdev, IORESOURCE_MEM));
  513. free_netdev(netdev);
  514. pci_disable_device(pdev);
  515. }
  516. static struct pci_driver igc_driver = {
  517. .name = igc_driver_name,
  518. .id_table = igc_pci_tbl,
  519. .probe = igc_probe,
  520. .remove = igc_remove,
  521. };
  522. /**
  523. * igc_sw_init - Initialize general software structures (struct igc_adapter)
  524. * @adapter: board private structure to initialize
  525. *
  526. * igc_sw_init initializes the Adapter private data structure.
  527. * Fields are initialized based on PCI device information and
  528. * OS network device settings (MTU size).
  529. */
  530. static int igc_sw_init(struct igc_adapter *adapter)
  531. {
  532. struct net_device *netdev = adapter->netdev;
  533. struct pci_dev *pdev = adapter->pdev;
  534. struct igc_hw *hw = &adapter->hw;
  535. /* PCI config space info */
  536. hw->vendor_id = pdev->vendor;
  537. hw->device_id = pdev->device;
  538. hw->subsystem_vendor_id = pdev->subsystem_vendor;
  539. hw->subsystem_device_id = pdev->subsystem_device;
  540. pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
  541. pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word);
  542. /* adjust max frame to be at least the size of a standard frame */
  543. adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN +
  544. VLAN_HLEN;
  545. set_bit(__IGC_DOWN, &adapter->state);
  546. return 0;
  547. }
  548. /**
  549. * igc_init_module - Driver Registration Routine
  550. *
  551. * igc_init_module is the first routine called when the driver is
  552. * loaded. All it does is register with the PCI subsystem.
  553. */
  554. static int __init igc_init_module(void)
  555. {
  556. int ret;
  557. pr_info("%s - version %s\n",
  558. igc_driver_string, igc_driver_version);
  559. pr_info("%s\n", igc_copyright);
  560. ret = pci_register_driver(&igc_driver);
  561. return ret;
  562. }
  563. module_init(igc_init_module);
  564. /**
  565. * igc_exit_module - Driver Exit Cleanup Routine
  566. *
  567. * igc_exit_module is called just before the driver is removed
  568. * from memory.
  569. */
  570. static void __exit igc_exit_module(void)
  571. {
  572. pci_unregister_driver(&igc_driver);
  573. }
  574. module_exit(igc_exit_module);
  575. /* igc_main.c */