0001
0002
0003
0004
0005
0006
0007
0008 #ifndef EFX_EFX_H
0009 #define EFX_EFX_H
0010
0011 #include <linux/indirect_call_wrapper.h>
0012 #include "net_driver.h"
0013 #include "filter.h"
0014
0015
0016 void efx_siena_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue);
0017 netdev_tx_t efx_siena_hard_start_xmit(struct sk_buff *skb,
0018 struct net_device *net_dev);
0019 netdev_tx_t __efx_siena_enqueue_skb(struct efx_tx_queue *tx_queue,
0020 struct sk_buff *skb);
0021 static inline netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
0022 {
0023 return INDIRECT_CALL_1(tx_queue->efx->type->tx_enqueue,
0024 __efx_siena_enqueue_skb, tx_queue, skb);
0025 }
0026 int efx_siena_setup_tc(struct net_device *net_dev, enum tc_setup_type type,
0027 void *type_data);
0028
0029
0030 void __efx_siena_rx_packet(struct efx_channel *channel);
0031 void efx_siena_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
0032 unsigned int n_frags, unsigned int len, u16 flags);
0033 static inline void efx_rx_flush_packet(struct efx_channel *channel)
0034 {
0035 if (channel->rx_pkt_n_frags)
0036 __efx_siena_rx_packet(channel);
0037 }
0038
0039
0040 #define EFX_TSO_MAX_SEGS 100
0041
0042
0043
0044
0045
0046 #define EFX_RXQ_MIN_ENT 128U
0047 #define EFX_TXQ_MIN_ENT(efx) (2 * efx_siena_tx_max_skb_descs(efx))
0048
0049
0050
0051
0052 #define EFX_TXQ_MAX_ENT(efx) (EFX_WORKAROUND_EF10(efx) ? \
0053 EFX_MAX_DMAQ_SIZE / 2 : EFX_MAX_DMAQ_SIZE)
0054
0055 static inline bool efx_rss_enabled(struct efx_nic *efx)
0056 {
0057 return efx->rss_spread > 1;
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 static inline s32 efx_filter_insert_filter(struct efx_nic *efx,
0088 struct efx_filter_spec *spec,
0089 bool replace_equal)
0090 {
0091 return efx->type->filter_insert(efx, spec, replace_equal);
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 static inline int efx_filter_remove_id_safe(struct efx_nic *efx,
0104 enum efx_filter_priority priority,
0105 u32 filter_id)
0106 {
0107 return efx->type->filter_remove_safe(efx, priority, filter_id);
0108 }
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 static inline int
0121 efx_filter_get_filter_safe(struct efx_nic *efx,
0122 enum efx_filter_priority priority,
0123 u32 filter_id, struct efx_filter_spec *spec)
0124 {
0125 return efx->type->filter_get_safe(efx, priority, filter_id, spec);
0126 }
0127
0128 static inline u32 efx_filter_count_rx_used(struct efx_nic *efx,
0129 enum efx_filter_priority priority)
0130 {
0131 return efx->type->filter_count_rx_used(efx, priority);
0132 }
0133 static inline u32 efx_filter_get_rx_id_limit(struct efx_nic *efx)
0134 {
0135 return efx->type->filter_get_rx_id_limit(efx);
0136 }
0137 static inline s32 efx_filter_get_rx_ids(struct efx_nic *efx,
0138 enum efx_filter_priority priority,
0139 u32 *buf, u32 size)
0140 {
0141 return efx->type->filter_get_rx_ids(efx, priority, buf, size);
0142 }
0143
0144
0145 static inline bool efx_rss_active(struct efx_rss_context *ctx)
0146 {
0147 return ctx->context_id != EFX_MCDI_RSS_CONTEXT_INVALID;
0148 }
0149
0150
0151 extern const struct ethtool_ops efx_siena_ethtool_ops;
0152
0153
0154 unsigned int efx_siena_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs);
0155 int efx_siena_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
0156 unsigned int rx_usecs, bool rx_adaptive,
0157 bool rx_may_override_tx);
0158 void efx_siena_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
0159 unsigned int *rx_usecs, bool *rx_adaptive);
0160
0161
0162 void efx_siena_update_sw_stats(struct efx_nic *efx, u64 *stats);
0163
0164
0165 #ifdef CONFIG_SFC_SIENA_MTD
0166 int efx_siena_mtd_add(struct efx_nic *efx, struct efx_mtd_partition *parts,
0167 size_t n_parts, size_t sizeof_part);
0168 static inline int efx_mtd_probe(struct efx_nic *efx)
0169 {
0170 return efx->type->mtd_probe(efx);
0171 }
0172 void efx_siena_mtd_rename(struct efx_nic *efx);
0173 void efx_siena_mtd_remove(struct efx_nic *efx);
0174 #else
0175 static inline int efx_mtd_probe(struct efx_nic *efx) { return 0; }
0176 static inline void efx_siena_mtd_rename(struct efx_nic *efx) {}
0177 static inline void efx_siena_mtd_remove(struct efx_nic *efx) {}
0178 #endif
0179
0180 #ifdef CONFIG_SFC_SIENA_SRIOV
0181 static inline unsigned int efx_vf_size(struct efx_nic *efx)
0182 {
0183 return 1 << efx->vi_scale;
0184 }
0185 #endif
0186
0187 static inline void efx_device_detach_sync(struct efx_nic *efx)
0188 {
0189 struct net_device *dev = efx->net_dev;
0190
0191
0192
0193
0194
0195 netif_tx_lock_bh(dev);
0196 netif_device_detach(dev);
0197 netif_tx_unlock_bh(dev);
0198 }
0199
0200 static inline void efx_device_attach_if_not_resetting(struct efx_nic *efx)
0201 {
0202 if ((efx->state != STATE_DISABLED) && !efx->reset_pending)
0203 netif_device_attach(efx->net_dev);
0204 }
0205
0206 static inline bool efx_rwsem_assert_write_locked(struct rw_semaphore *sem)
0207 {
0208 if (WARN_ON(down_read_trylock(sem))) {
0209 up_read(sem);
0210 return false;
0211 }
0212 return true;
0213 }
0214
0215 int efx_siena_xdp_tx_buffers(struct efx_nic *efx, int n,
0216 struct xdp_frame **xdpfs, bool flush);
0217
0218 #endif