13 #ifndef EFX_NET_DRIVER_H
14 #define EFX_NET_DRIVER_H
16 #include <linux/netdevice.h>
18 #include <linux/ethtool.h>
19 #include <linux/if_vlan.h>
21 #include <linux/mdio.h>
22 #include <linux/list.h>
23 #include <linux/pci.h>
24 #include <linux/device.h>
29 #include <linux/i2c.h>
40 #define EFX_DRIVER_VERSION "3.2"
43 #define EFX_BUG_ON_PARANOID(x) BUG_ON(x)
44 #define EFX_WARN_ON_PARANOID(x) WARN_ON(x)
46 #define EFX_BUG_ON_PARANOID(x) do {} while (0)
47 #define EFX_WARN_ON_PARANOID(x) do {} while (0)
56 #define EFX_MAX_CHANNELS 32U
57 #define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS
58 #define EFX_EXTRA_CHANNEL_IOV 0
59 #define EFX_EXTRA_CHANNEL_PTP 1
60 #define EFX_MAX_EXTRA_CHANNELS 2U
65 #define EFX_MAX_TX_TC 2
66 #define EFX_MAX_CORE_TX_QUEUES (EFX_MAX_TX_TC * EFX_MAX_CHANNELS)
67 #define EFX_TXQ_TYPE_OFFLOAD 1
68 #define EFX_TXQ_TYPE_HIGHPRI 2
69 #define EFX_TXQ_TYPES 4
70 #define EFX_MAX_TX_QUEUES (EFX_TXQ_TYPES * EFX_MAX_CHANNELS)
119 #define EFX_TX_BUF_CONT 1
120 #define EFX_TX_BUF_SKB 2
121 #define EFX_TX_BUF_HEAP 4
122 #define EFX_TX_BUF_MAP_SINGLE 8
202 #define EFX_EMPTY_COUNT_VALID 0x80000000
224 #define EFX_RX_BUF_PAGE 0x0001
225 #define EFX_RX_PKT_CSUMMED 0x0002
226 #define EFX_RX_PKT_DISCARD 0x0004
367 #ifdef CONFIG_RFS_ACCEL
368 unsigned int rfs_filters_added;
420 #define STRING_TABLE_LOOKUP(val, member) \
421 ((val) < member ## _max) ? member ## _names[val] : "(invalid)"
425 #define LOOPBACK_MODE(efx) \
426 STRING_TABLE_LOOKUP((efx)->loopback_mode, efx_loopback_mode)
430 #define RESET_TYPE(type) \
431 STRING_TABLE_LOOKUP(type, efx_reset_type)
440 #define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI)
455 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
456 #define EFX_PAGE_IP_ALIGN 0
458 #define EFX_PAGE_IP_ALIGN NET_IP_ALIGN
468 #define EFX_PAGE_SKB_ALIGN 2
474 #define EFX_FC_RX FLOW_CTRL_RX
475 #define EFX_FC_TX FLOW_CTRL_TX
476 #define EFX_FC_AUTO 4
495 return left->
up == right->
up && left->
fd == right->
fd &&
632 #define EFX_MCAST_HASH_BITS 8
635 #define EFX_MCAST_HASH_ENTRIES (1 << EFX_MCAST_HASH_BITS)
813 #ifdef CONFIG_SFC_MTD
857 #ifdef CONFIG_SFC_SRIOV
861 unsigned vf_init_count;
863 unsigned vf_buftbl_base;
867 struct mutex local_lock;
871 #ifdef CONFIG_SFC_PTP
885 static inline int efx_dev_registered(
struct efx_nic *efx)
887 return efx->
net_dev->reg_state == NETREG_REGISTERED;
890 static inline unsigned int efx_port_num(
struct efx_nic *efx)
1003 #define efx_for_each_channel(_channel, _efx) \
1004 for (_channel = (_efx)->channel[0]; \
1006 _channel = (_channel->channel + 1 < (_efx)->n_channels) ? \
1007 (_efx)->channel[_channel->channel + 1] : NULL)
1010 #define efx_for_each_channel_rev(_channel, _efx) \
1011 for (_channel = (_efx)->channel[(_efx)->n_channels - 1]; \
1013 _channel = _channel->channel ? \
1014 (_efx)->channel[_channel->channel - 1] : NULL)
1026 return channel->
channel - channel->
efx->tx_channel_offset <
1027 channel->
efx->n_tx_channels;
1040 return !(tx_queue->efx->net_dev->num_tc < 2 &&
1045 #define efx_for_each_channel_tx_queue(_tx_queue, _channel) \
1046 if (!efx_channel_has_tx_queues(_channel)) \
1049 for (_tx_queue = (_channel)->tx_queue; \
1050 _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES && \
1051 efx_tx_queue_used(_tx_queue); \
1055 #define efx_for_each_possible_channel_tx_queue(_tx_queue, _channel) \
1056 if (!efx_channel_has_tx_queues(_channel)) \
1059 for (_tx_queue = (_channel)->tx_queue; \
1060 _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \
1063 static inline bool efx_channel_has_rx_queue(
struct efx_channel *channel)
1065 return channel->
rx_queue.core_index >= 0;
1069 efx_channel_get_rx_queue(
struct efx_channel *channel)
1076 #define efx_for_each_channel_rx_queue(_rx_queue, _channel) \
1077 if (!efx_channel_has_rx_queue(_channel)) \
1080 for (_rx_queue = &(_channel)->rx_queue; \
1092 return efx_rx_queue_channel(rx_queue)->channel;
1122 #define EFX_MAX_FRAME_LEN(mtu) \
1123 ((((mtu) + ETH_HLEN + VLAN_HLEN + 4 + 7) & ~7) + 16)
1125 static inline bool efx_xmit_with_hwtstamp(
struct sk_buff *
skb)
1129 static inline void efx_xmit_hwtstamp_pending(
struct sk_buff *
skb)