aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/net_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc/net_driver.h')
-rw-r--r--drivers/net/sfc/net_driver.h136
1 files changed, 70 insertions, 66 deletions
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 219c74a772c3..567df00090fb 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -88,9 +88,12 @@ do {if (net_ratelimit()) EFX_LOG(efx, fmt, ##args); } while (0)
88 **************************************************************************/ 88 **************************************************************************/
89 89
90#define EFX_MAX_CHANNELS 32 90#define EFX_MAX_CHANNELS 32
91#define EFX_MAX_TX_QUEUES 1
92#define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS 91#define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS
93 92
93#define EFX_TX_QUEUE_OFFLOAD_CSUM 0
94#define EFX_TX_QUEUE_NO_CSUM 1
95#define EFX_TX_QUEUE_COUNT 2
96
94/** 97/**
95 * struct efx_special_buffer - An Efx special buffer 98 * struct efx_special_buffer - An Efx special buffer
96 * @addr: CPU base address of the buffer 99 * @addr: CPU base address of the buffer
@@ -127,7 +130,6 @@ struct efx_special_buffer {
127 * This field is zero when the queue slot is empty. 130 * This field is zero when the queue slot is empty.
128 * @continuation: True if this fragment is not the end of a packet. 131 * @continuation: True if this fragment is not the end of a packet.
129 * @unmap_single: True if pci_unmap_single should be used. 132 * @unmap_single: True if pci_unmap_single should be used.
130 * @unmap_addr: DMA address to unmap
131 * @unmap_len: Length of this fragment to unmap 133 * @unmap_len: Length of this fragment to unmap
132 */ 134 */
133struct efx_tx_buffer { 135struct efx_tx_buffer {
@@ -135,9 +137,8 @@ struct efx_tx_buffer {
135 struct efx_tso_header *tsoh; 137 struct efx_tso_header *tsoh;
136 dma_addr_t dma_addr; 138 dma_addr_t dma_addr;
137 unsigned short len; 139 unsigned short len;
138 unsigned char continuation; 140 bool continuation;
139 unsigned char unmap_single; 141 bool unmap_single;
140 dma_addr_t unmap_addr;
141 unsigned short unmap_len; 142 unsigned short unmap_len;
142}; 143};
143 144
@@ -156,13 +157,12 @@ struct efx_tx_buffer {
156 * 157 *
157 * @efx: The associated Efx NIC 158 * @efx: The associated Efx NIC
158 * @queue: DMA queue number 159 * @queue: DMA queue number
159 * @used: Queue is used by net driver
160 * @channel: The associated channel 160 * @channel: The associated channel
161 * @buffer: The software buffer ring 161 * @buffer: The software buffer ring
162 * @txd: The hardware descriptor ring 162 * @txd: The hardware descriptor ring
163 * @read_count: Current read pointer. 163 * @read_count: Current read pointer.
164 * This is the number of buffers that have been removed from both rings. 164 * This is the number of buffers that have been removed from both rings.
165 * @stopped: Stopped flag. 165 * @stopped: Stopped count.
166 * Set if this TX queue is currently stopping its port. 166 * Set if this TX queue is currently stopping its port.
167 * @insert_count: Current insert pointer 167 * @insert_count: Current insert pointer
168 * This is the number of buffers that have been added to the 168 * This is the number of buffers that have been added to the
@@ -188,7 +188,6 @@ struct efx_tx_queue {
188 /* Members which don't change on the fast path */ 188 /* Members which don't change on the fast path */
189 struct efx_nic *efx ____cacheline_aligned_in_smp; 189 struct efx_nic *efx ____cacheline_aligned_in_smp;
190 int queue; 190 int queue;
191 int used;
192 struct efx_channel *channel; 191 struct efx_channel *channel;
193 struct efx_nic *nic; 192 struct efx_nic *nic;
194 struct efx_tx_buffer *buffer; 193 struct efx_tx_buffer *buffer;
@@ -232,7 +231,6 @@ struct efx_rx_buffer {
232 * struct efx_rx_queue - An Efx RX queue 231 * struct efx_rx_queue - An Efx RX queue
233 * @efx: The associated Efx NIC 232 * @efx: The associated Efx NIC
234 * @queue: DMA queue number 233 * @queue: DMA queue number
235 * @used: Queue is used by net driver
236 * @channel: The associated channel 234 * @channel: The associated channel
237 * @buffer: The software buffer ring 235 * @buffer: The software buffer ring
238 * @rxd: The hardware descriptor ring 236 * @rxd: The hardware descriptor ring
@@ -266,7 +264,6 @@ struct efx_rx_buffer {
266struct efx_rx_queue { 264struct efx_rx_queue {
267 struct efx_nic *efx; 265 struct efx_nic *efx;
268 int queue; 266 int queue;
269 int used;
270 struct efx_channel *channel; 267 struct efx_channel *channel;
271 struct efx_rx_buffer *buffer; 268 struct efx_rx_buffer *buffer;
272 struct efx_special_buffer rxd; 269 struct efx_special_buffer rxd;
@@ -325,12 +322,10 @@ enum efx_rx_alloc_method {
325 * queue. 322 * queue.
326 * 323 *
327 * @efx: Associated Efx NIC 324 * @efx: Associated Efx NIC
328 * @evqnum: Event queue number
329 * @channel: Channel instance number 325 * @channel: Channel instance number
330 * @used_flags: Channel is used by net driver 326 * @used_flags: Channel is used by net driver
331 * @enabled: Channel enabled indicator 327 * @enabled: Channel enabled indicator
332 * @irq: IRQ number (MSI and MSI-X only) 328 * @irq: IRQ number (MSI and MSI-X only)
333 * @has_interrupt: Channel has an interrupt
334 * @irq_moderation: IRQ moderation value (in us) 329 * @irq_moderation: IRQ moderation value (in us)
335 * @napi_dev: Net device used with NAPI 330 * @napi_dev: Net device used with NAPI
336 * @napi_str: NAPI control structure 331 * @napi_str: NAPI control structure
@@ -357,17 +352,14 @@ enum efx_rx_alloc_method {
357 */ 352 */
358struct efx_channel { 353struct efx_channel {
359 struct efx_nic *efx; 354 struct efx_nic *efx;
360 int evqnum;
361 int channel; 355 int channel;
362 int used_flags; 356 int used_flags;
363 int enabled; 357 bool enabled;
364 int irq; 358 int irq;
365 unsigned int has_interrupt;
366 unsigned int irq_moderation; 359 unsigned int irq_moderation;
367 struct net_device *napi_dev; 360 struct net_device *napi_dev;
368 struct napi_struct napi_str; 361 struct napi_struct napi_str;
369 struct work_struct reset_work; 362 bool work_pending;
370 int work_pending;
371 struct efx_special_buffer eventq; 363 struct efx_special_buffer eventq;
372 unsigned int eventq_read_ptr; 364 unsigned int eventq_read_ptr;
373 unsigned int last_eventq_read_ptr; 365 unsigned int last_eventq_read_ptr;
@@ -390,7 +382,7 @@ struct efx_channel {
390 * access with prefetches. 382 * access with prefetches.
391 */ 383 */
392 struct efx_rx_buffer *rx_pkt; 384 struct efx_rx_buffer *rx_pkt;
393 int rx_pkt_csummed; 385 bool rx_pkt_csummed;
394 386
395}; 387};
396 388
@@ -403,8 +395,8 @@ struct efx_channel {
403 */ 395 */
404struct efx_blinker { 396struct efx_blinker {
405 int led_num; 397 int led_num;
406 int state; 398 bool state;
407 int resubmit; 399 bool resubmit;
408 struct timer_list timer; 400 struct timer_list timer;
409}; 401};
410 402
@@ -432,8 +424,8 @@ struct efx_board {
432 * have a separate init callback that happens later than 424 * have a separate init callback that happens later than
433 * board init. */ 425 * board init. */
434 int (*init_leds)(struct efx_nic *efx); 426 int (*init_leds)(struct efx_nic *efx);
435 void (*set_fault_led) (struct efx_nic *efx, int state); 427 void (*set_fault_led) (struct efx_nic *efx, bool state);
436 void (*blink) (struct efx_nic *efx, int start); 428 void (*blink) (struct efx_nic *efx, bool start);
437 void (*fini) (struct efx_nic *nic); 429 void (*fini) (struct efx_nic *nic);
438 struct efx_blinker blinker; 430 struct efx_blinker blinker;
439 struct i2c_client *hwmon_client, *ioexp_client; 431 struct i2c_client *hwmon_client, *ioexp_client;
@@ -467,8 +459,7 @@ enum nic_state {
467 STATE_INIT = 0, 459 STATE_INIT = 0,
468 STATE_RUNNING = 1, 460 STATE_RUNNING = 1,
469 STATE_FINI = 2, 461 STATE_FINI = 2,
470 STATE_RESETTING = 3, /* rtnl_lock always held */ 462 STATE_DISABLED = 3,
471 STATE_DISABLED = 4,
472 STATE_MAX, 463 STATE_MAX,
473}; 464};
474 465
@@ -523,10 +514,28 @@ struct efx_phy_operations {
523 void (*clear_interrupt) (struct efx_nic *efx); 514 void (*clear_interrupt) (struct efx_nic *efx);
524 int (*check_hw) (struct efx_nic *efx); 515 int (*check_hw) (struct efx_nic *efx);
525 void (*reset_xaui) (struct efx_nic *efx); 516 void (*reset_xaui) (struct efx_nic *efx);
517 int (*test) (struct efx_nic *efx);
526 int mmds; 518 int mmds;
527 unsigned loopbacks; 519 unsigned loopbacks;
528}; 520};
529 521
522/**
523 * @enum efx_phy_mode - PHY operating mode flags
524 * @PHY_MODE_NORMAL: on and should pass traffic
525 * @PHY_MODE_TX_DISABLED: on with TX disabled
526 * @PHY_MODE_SPECIAL: on but will not pass traffic
527 */
528enum efx_phy_mode {
529 PHY_MODE_NORMAL = 0,
530 PHY_MODE_TX_DISABLED = 1,
531 PHY_MODE_SPECIAL = 8,
532};
533
534static inline bool efx_phy_mode_disabled(enum efx_phy_mode mode)
535{
536 return !!(mode & ~PHY_MODE_TX_DISABLED);
537}
538
530/* 539/*
531 * Efx extended statistics 540 * Efx extended statistics
532 * 541 *
@@ -632,7 +641,7 @@ union efx_multicast_hash {
632 * @tx_queue: TX DMA queues 641 * @tx_queue: TX DMA queues
633 * @rx_queue: RX DMA queues 642 * @rx_queue: RX DMA queues
634 * @channel: Channels 643 * @channel: Channels
635 * @rss_queues: Number of RSS queues 644 * @n_rx_queues: Number of RX queues
636 * @rx_buffer_len: RX buffer length 645 * @rx_buffer_len: RX buffer length
637 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer 646 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
638 * @irq_status: Interrupt status buffer 647 * @irq_status: Interrupt status buffer
@@ -640,15 +649,20 @@ union efx_multicast_hash {
640 * This register is written with the SMP processor ID whenever an 649 * This register is written with the SMP processor ID whenever an
641 * interrupt is handled. It is used by falcon_test_interrupt() 650 * interrupt is handled. It is used by falcon_test_interrupt()
642 * to verify that an interrupt has occurred. 651 * to verify that an interrupt has occurred.
652 * @spi_flash: SPI flash device
653 * This field will be %NULL if no flash device is present.
654 * @spi_eeprom: SPI EEPROM device
655 * This field will be %NULL if no EEPROM device is present.
643 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count 656 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
644 * @nic_data: Hardware dependant state 657 * @nic_data: Hardware dependant state
645 * @mac_lock: MAC access lock. Protects @port_enabled, efx_monitor() and 658 * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode,
646 * efx_reconfigure_port() 659 * @port_inhibited, efx_monitor() and efx_reconfigure_port()
647 * @port_enabled: Port enabled indicator. 660 * @port_enabled: Port enabled indicator.
648 * Serialises efx_stop_all(), efx_start_all() and efx_monitor() and 661 * Serialises efx_stop_all(), efx_start_all() and efx_monitor() and
649 * efx_reconfigure_work with kernel interfaces. Safe to read under any 662 * efx_reconfigure_work with kernel interfaces. Safe to read under any
650 * one of the rtnl_lock, mac_lock, or netif_tx_lock, but all three must 663 * one of the rtnl_lock, mac_lock, or netif_tx_lock, but all three must
651 * be held to modify it. 664 * be held to modify it.
665 * @port_inhibited: If set, the netif_carrier is always off. Hold the mac_lock
652 * @port_initialized: Port initialized? 666 * @port_initialized: Port initialized?
653 * @net_dev: Operating system network device. Consider holding the rtnl lock 667 * @net_dev: Operating system network device. Consider holding the rtnl lock
654 * @rx_checksum_enabled: RX checksumming enabled 668 * @rx_checksum_enabled: RX checksumming enabled
@@ -658,14 +672,16 @@ union efx_multicast_hash {
658 * can provide. Generic code converts these into a standard 672 * can provide. Generic code converts these into a standard
659 * &struct net_device_stats. 673 * &struct net_device_stats.
660 * @stats_buffer: DMA buffer for statistics 674 * @stats_buffer: DMA buffer for statistics
661 * @stats_lock: Statistics update lock 675 * @stats_lock: Statistics update lock. Serialises statistics fetches
676 * @stats_enabled: Temporarily disable statistics fetches.
677 * Serialised by @stats_lock
662 * @mac_address: Permanent MAC address 678 * @mac_address: Permanent MAC address
663 * @phy_type: PHY type 679 * @phy_type: PHY type
664 * @phy_lock: PHY access lock 680 * @phy_lock: PHY access lock
665 * @phy_op: PHY interface 681 * @phy_op: PHY interface
666 * @phy_data: PHY private data (including PHY-specific stats) 682 * @phy_data: PHY private data (including PHY-specific stats)
667 * @mii: PHY interface 683 * @mii: PHY interface
668 * @tx_disabled: PHY transmitter turned off 684 * @phy_mode: PHY operating mode. Serialised by @mac_lock.
669 * @link_up: Link status 685 * @link_up: Link status
670 * @link_options: Link options (MII/GMII format) 686 * @link_options: Link options (MII/GMII format)
671 * @n_link_state_changes: Number of times the link has changed state 687 * @n_link_state_changes: Number of times the link has changed state
@@ -700,27 +716,31 @@ struct efx_nic {
700 enum nic_state state; 716 enum nic_state state;
701 enum reset_type reset_pending; 717 enum reset_type reset_pending;
702 718
703 struct efx_tx_queue tx_queue[EFX_MAX_TX_QUEUES]; 719 struct efx_tx_queue tx_queue[EFX_TX_QUEUE_COUNT];
704 struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES]; 720 struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES];
705 struct efx_channel channel[EFX_MAX_CHANNELS]; 721 struct efx_channel channel[EFX_MAX_CHANNELS];
706 722
707 int rss_queues; 723 int n_rx_queues;
708 unsigned int rx_buffer_len; 724 unsigned int rx_buffer_len;
709 unsigned int rx_buffer_order; 725 unsigned int rx_buffer_order;
710 726
711 struct efx_buffer irq_status; 727 struct efx_buffer irq_status;
712 volatile signed int last_irq_cpu; 728 volatile signed int last_irq_cpu;
713 729
730 struct efx_spi_device *spi_flash;
731 struct efx_spi_device *spi_eeprom;
732
714 unsigned n_rx_nodesc_drop_cnt; 733 unsigned n_rx_nodesc_drop_cnt;
715 734
716 struct falcon_nic_data *nic_data; 735 struct falcon_nic_data *nic_data;
717 736
718 struct mutex mac_lock; 737 struct mutex mac_lock;
719 int port_enabled; 738 bool port_enabled;
739 bool port_inhibited;
720 740
721 int port_initialized; 741 bool port_initialized;
722 struct net_device *net_dev; 742 struct net_device *net_dev;
723 int rx_checksum_enabled; 743 bool rx_checksum_enabled;
724 744
725 atomic_t netif_stop_count; 745 atomic_t netif_stop_count;
726 spinlock_t netif_stop_lock; 746 spinlock_t netif_stop_lock;
@@ -728,6 +748,7 @@ struct efx_nic {
728 struct efx_mac_stats mac_stats; 748 struct efx_mac_stats mac_stats;
729 struct efx_buffer stats_buffer; 749 struct efx_buffer stats_buffer;
730 spinlock_t stats_lock; 750 spinlock_t stats_lock;
751 bool stats_enabled;
731 752
732 unsigned char mac_address[ETH_ALEN]; 753 unsigned char mac_address[ETH_ALEN];
733 754
@@ -736,13 +757,13 @@ struct efx_nic {
736 struct efx_phy_operations *phy_op; 757 struct efx_phy_operations *phy_op;
737 void *phy_data; 758 void *phy_data;
738 struct mii_if_info mii; 759 struct mii_if_info mii;
739 unsigned tx_disabled; 760 enum efx_phy_mode phy_mode;
740 761
741 int link_up; 762 bool link_up;
742 unsigned int link_options; 763 unsigned int link_options;
743 unsigned int n_link_state_changes; 764 unsigned int n_link_state_changes;
744 765
745 int promiscuous; 766 bool promiscuous;
746 union efx_multicast_hash multicast_hash; 767 union efx_multicast_hash multicast_hash;
747 enum efx_fc_type flow_control; 768 enum efx_fc_type flow_control;
748 struct work_struct reconfigure_work; 769 struct work_struct reconfigure_work;
@@ -829,50 +850,33 @@ struct efx_nic_type {
829 continue; \ 850 continue; \
830 else 851 else
831 852
832/* Iterate over all used channels with interrupts */
833#define efx_for_each_channel_with_interrupt(_channel, _efx) \
834 for (_channel = &_efx->channel[0]; \
835 _channel < &_efx->channel[EFX_MAX_CHANNELS]; \
836 _channel++) \
837 if (!(_channel->used_flags && _channel->has_interrupt)) \
838 continue; \
839 else
840
841/* Iterate over all used TX queues */ 853/* Iterate over all used TX queues */
842#define efx_for_each_tx_queue(_tx_queue, _efx) \ 854#define efx_for_each_tx_queue(_tx_queue, _efx) \
843 for (_tx_queue = &_efx->tx_queue[0]; \ 855 for (_tx_queue = &_efx->tx_queue[0]; \
844 _tx_queue < &_efx->tx_queue[EFX_MAX_TX_QUEUES]; \ 856 _tx_queue < &_efx->tx_queue[EFX_TX_QUEUE_COUNT]; \
845 _tx_queue++) \ 857 _tx_queue++)
846 if (!_tx_queue->used) \
847 continue; \
848 else
849 858
850/* Iterate over all TX queues belonging to a channel */ 859/* Iterate over all TX queues belonging to a channel */
851#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \ 860#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \
852 for (_tx_queue = &_channel->efx->tx_queue[0]; \ 861 for (_tx_queue = &_channel->efx->tx_queue[0]; \
853 _tx_queue < &_channel->efx->tx_queue[EFX_MAX_TX_QUEUES]; \ 862 _tx_queue < &_channel->efx->tx_queue[EFX_TX_QUEUE_COUNT]; \
854 _tx_queue++) \ 863 _tx_queue++) \
855 if ((!_tx_queue->used) || \ 864 if (_tx_queue->channel != _channel) \
856 (_tx_queue->channel != _channel)) \
857 continue; \ 865 continue; \
858 else 866 else
859 867
860/* Iterate over all used RX queues */ 868/* Iterate over all used RX queues */
861#define efx_for_each_rx_queue(_rx_queue, _efx) \ 869#define efx_for_each_rx_queue(_rx_queue, _efx) \
862 for (_rx_queue = &_efx->rx_queue[0]; \ 870 for (_rx_queue = &_efx->rx_queue[0]; \
863 _rx_queue < &_efx->rx_queue[EFX_MAX_RX_QUEUES]; \ 871 _rx_queue < &_efx->rx_queue[_efx->n_rx_queues]; \
864 _rx_queue++) \ 872 _rx_queue++)
865 if (!_rx_queue->used) \
866 continue; \
867 else
868 873
869/* Iterate over all RX queues belonging to a channel */ 874/* Iterate over all RX queues belonging to a channel */
870#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \ 875#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \
871 for (_rx_queue = &_channel->efx->rx_queue[0]; \ 876 for (_rx_queue = &_channel->efx->rx_queue[_channel->channel]; \
872 _rx_queue < &_channel->efx->rx_queue[EFX_MAX_RX_QUEUES]; \ 877 _rx_queue; \
873 _rx_queue++) \ 878 _rx_queue = NULL) \
874 if ((!_rx_queue->used) || \ 879 if (_rx_queue->channel != _channel) \
875 (_rx_queue->channel != _channel)) \
876 continue; \ 880 continue; \
877 else 881 else
878 882
@@ -886,13 +890,13 @@ static inline struct efx_rx_buffer *efx_rx_buffer(struct efx_rx_queue *rx_queue,
886} 890}
887 891
888/* Set bit in a little-endian bitfield */ 892/* Set bit in a little-endian bitfield */
889static inline void set_bit_le(int nr, unsigned char *addr) 893static inline void set_bit_le(unsigned nr, unsigned char *addr)
890{ 894{
891 addr[nr / 8] |= (1 << (nr % 8)); 895 addr[nr / 8] |= (1 << (nr % 8));
892} 896}
893 897
894/* Clear bit in a little-endian bitfield */ 898/* Clear bit in a little-endian bitfield */
895static inline void clear_bit_le(int nr, unsigned char *addr) 899static inline void clear_bit_le(unsigned nr, unsigned char *addr)
896{ 900{
897 addr[nr / 8] &= ~(1 << (nr % 8)); 901 addr[nr / 8] &= ~(1 << (nr % 8));
898} 902}