]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/sfc/net_driver.h
sfc: Prepare for RX scatter on EF10
[karo-tx-linux.git] / drivers / net / ethernet / sfc / net_driver.h
index fa881cdd9dcc12e5fa861384c0f0d57d801b19f2..5341c76b1d024e5477374961cc8c646d8971bb67 100644 (file)
@@ -186,6 +186,7 @@ struct efx_tx_buffer {
  *     variable indicates that the queue is empty.  This is to
  *     avoid cache-line ping-pong between the xmit path and the
  *     completion path.
+ * @merge_events: Number of TX merged completion events
  * @insert_count: Current insert pointer
  *     This is the number of buffers that have been added to the
  *     software ring.
@@ -222,6 +223,7 @@ struct efx_tx_queue {
        /* Members used mainly on the completion path */
        unsigned int read_count ____cacheline_aligned_in_smp;
        unsigned int old_write_count;
+       unsigned int merge_events;
 
        /* Members used only on the xmit path */
        unsigned int insert_count ____cacheline_aligned_in_smp;
@@ -261,6 +263,7 @@ struct efx_rx_buffer {
 #define EFX_RX_PKT_CSUMMED     0x0002
 #define EFX_RX_PKT_DISCARD     0x0004
 #define EFX_RX_PKT_TCP         0x0040
+#define EFX_RX_PKT_PREFIX_LEN  0x0080  /* length is in prefix only */
 
 /**
  * struct efx_rx_page_state - Page-based rx buffer state
@@ -294,7 +297,8 @@ struct efx_rx_page_state {
  * @added_count: Number of buffers added to the receive queue.
  * @notified_count: Number of buffers given to NIC (<= @added_count).
  * @removed_count: Number of buffers removed from the receive queue.
- * @scatter_n: Number of buffers used by current packet
+ * @scatter_n: Used by NIC specific receive code.
+ * @scatter_len: Used by NIC specific receive code.
  * @page_ring: The ring to store DMA mapped pages for reuse.
  * @page_add: Counter to calculate the write pointer for the recycle ring.
  * @page_remove: Counter to calculate the read pointer for the recycle ring.
@@ -326,6 +330,7 @@ struct efx_rx_queue {
        unsigned int notified_count;
        unsigned int removed_count;
        unsigned int scatter_n;
+       unsigned int scatter_len;
        struct page **page_ring;
        unsigned int page_add;
        unsigned int page_remove;
@@ -595,75 +600,17 @@ static inline bool efx_phy_mode_disabled(enum efx_phy_mode mode)
        return !!(mode & ~PHY_MODE_TX_DISABLED);
 }
 
-/*
- * Efx extended statistics
- *
- * Not all statistics are provided by all supported MACs.  The purpose
- * is this structure is to contain the raw statistics provided by each
- * MAC.
+/**
+ * struct efx_hw_stat_desc - Description of a hardware statistic
+ * @name: Name of the statistic as visible through ethtool, or %NULL if
+ *     it should not be exposed
+ * @dma_width: Width in bits (0 for non-DMA statistics)
+ * @offset: Offset within stats (ignored for non-DMA statistics)
  */
-struct efx_mac_stats {
-       u64 tx_bytes;
-       u64 tx_good_bytes;
-       u64 tx_bad_bytes;
-       u64 tx_packets;
-       u64 tx_bad;
-       u64 tx_pause;
-       u64 tx_control;
-       u64 tx_unicast;
-       u64 tx_multicast;
-       u64 tx_broadcast;
-       u64 tx_lt64;
-       u64 tx_64;
-       u64 tx_65_to_127;
-       u64 tx_128_to_255;
-       u64 tx_256_to_511;
-       u64 tx_512_to_1023;
-       u64 tx_1024_to_15xx;
-       u64 tx_15xx_to_jumbo;
-       u64 tx_gtjumbo;
-       u64 tx_collision;
-       u64 tx_single_collision;
-       u64 tx_multiple_collision;
-       u64 tx_excessive_collision;
-       u64 tx_deferred;
-       u64 tx_late_collision;
-       u64 tx_excessive_deferred;
-       u64 tx_non_tcpudp;
-       u64 tx_mac_src_error;
-       u64 tx_ip_src_error;
-       u64 rx_bytes;
-       u64 rx_good_bytes;
-       u64 rx_bad_bytes;
-       u64 rx_packets;
-       u64 rx_good;
-       u64 rx_bad;
-       u64 rx_pause;
-       u64 rx_control;
-       u64 rx_unicast;
-       u64 rx_multicast;
-       u64 rx_broadcast;
-       u64 rx_lt64;
-       u64 rx_64;
-       u64 rx_65_to_127;
-       u64 rx_128_to_255;
-       u64 rx_256_to_511;
-       u64 rx_512_to_1023;
-       u64 rx_1024_to_15xx;
-       u64 rx_15xx_to_jumbo;
-       u64 rx_gtjumbo;
-       u64 rx_bad_lt64;
-       u64 rx_bad_64_to_15xx;
-       u64 rx_bad_15xx_to_jumbo;
-       u64 rx_bad_gtjumbo;
-       u64 rx_overflow;
-       u64 rx_missed;
-       u64 rx_false_carrier;
-       u64 rx_symbol_error;
-       u64 rx_align_error;
-       u64 rx_length_error;
-       u64 rx_internal_error;
-       u64 rx_good_lt64;
+struct efx_hw_stat_desc {
+       const char *name;
+       u16 dma_width;
+       u16 offset;
 };
 
 /* Number of bits used in a multicast filter hash address */
@@ -721,6 +668,11 @@ struct vfdi_status;
  * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
  * @rx_buffer_truesize: Amortised allocation size of an RX buffer,
  *     for use in sk_buff::truesize
+ * @rx_prefix_size: Size of RX prefix before packet data
+ * @rx_packet_hash_offset: Offset of RX flow hash from start of packet data
+ *     (valid only if @rx_prefix_size != 0; always negative)
+ * @rx_packet_len_offset: Offset of RX packet length from start of packet data
+ *     (valid only for NICs that set %EFX_RX_PKT_PREFIX_LEN; always negative)
  * @rx_hash_key: Toeplitz hash key for RSS
  * @rx_indir_table: Indirection table for RSS
  * @rx_scatter: Scatter mode enabled for receives
@@ -795,12 +747,8 @@ struct vfdi_status;
  * @last_irq_cpu: Last CPU to handle a possible test interrupt.  This
  *     field is used by efx_test_interrupts() to verify that an
  *     interrupt has occurred.
- * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
- * @mac_stats: MAC statistics. These include all statistics the MACs
- *     can provide.  Generic code converts these into a standard
- *     &struct net_device_stats.
- * @stats_lock: Statistics update lock. Serialises statistics fetches
- *     and access to @mac_stats.
+ * @stats_lock: Statistics update lock. Must be held when calling
+ *     efx_nic_type::{update,start,stop}_stats.
  *
  * This is stored in the private area of the &struct net_device.
  */
@@ -855,6 +803,9 @@ struct efx_nic {
        unsigned int rx_page_buf_step;
        unsigned int rx_bufs_per_page;
        unsigned int rx_pages_per_batch;
+       unsigned int rx_prefix_size;
+       int rx_packet_hash_offset;
+       int rx_packet_len_offset;
        u8 rx_hash_key[40];
        u32 rx_indir_table[128];
        bool rx_scatter;
@@ -939,8 +890,6 @@ struct efx_nic {
        struct delayed_work monitor_work ____cacheline_aligned_in_smp;
        spinlock_t biu_lock;
        int last_irq_cpu;
-       unsigned n_rx_nodesc_drop_cnt;
-       struct efx_mac_stats mac_stats;
        spinlock_t stats_lock;
 };
 
@@ -984,7 +933,9 @@ struct efx_mtd_partition {
  *     (for Falcon architecture)
  * @finish_flush: Clean up after flushing the DMA queues (for Falcon
  *     architecture)
- * @update_stats: Update statistics not provided by event handling
+ * @describe_stats: Describe statistics for ethtool
+ * @update_stats: Update statistics not provided by event handling.
+ *     Either argument may be %NULL.
  * @start_stats: Start the regular fetching of statistics
  * @stop_stats: Stop the regular fetching of statistics
  * @set_id_led: Set state of identifying LED or revert to automatic function
@@ -1071,9 +1022,11 @@ struct efx_mtd_partition {
  * @evq_ptr_tbl_base: Event queue pointer table base address
  * @evq_rptr_tbl_base: Event queue read-pointer table base address
  * @max_dma_mask: Maximum possible DMA mask
- * @rx_buffer_hash_size: Size of hash at start of RX packet
+ * @rx_prefix_size: Size of RX prefix before packet data
+ * @rx_hash_offset: Offset of RX flow hash within prefix
  * @rx_buffer_padding: Size of padding at end of RX packet
- * @can_rx_scatter: NIC is able to scatter packet to multiple buffers
+ * @can_rx_scatter: NIC is able to scatter packets to multiple buffers
+ * @always_rx_scatter: NIC will always scatter packets to multiple buffers
  * @max_interrupt_mode: Highest capability interrupt mode supported
  *     from &enum efx_init_mode.
  * @timer_period_max: Maximum period of interrupt timer (in ticks)
@@ -1086,7 +1039,7 @@ struct efx_nic_type {
        int (*probe)(struct efx_nic *efx);
        void (*remove)(struct efx_nic *efx);
        int (*init)(struct efx_nic *efx);
-       void (*dimension_resources)(struct efx_nic *efx);
+       int (*dimension_resources)(struct efx_nic *efx);
        void (*fini)(struct efx_nic *efx);
        void (*monitor)(struct efx_nic *efx);
        enum reset_type (*map_reset_reason)(enum reset_type reason);
@@ -1098,7 +1051,9 @@ struct efx_nic_type {
        int (*fini_dmaq)(struct efx_nic *efx);
        void (*prepare_flush)(struct efx_nic *efx);
        void (*finish_flush)(struct efx_nic *efx);
-       void (*update_stats)(struct efx_nic *efx);
+       size_t (*describe_stats)(struct efx_nic *efx, u8 *names);
+       size_t (*update_stats)(struct efx_nic *efx, u64 *full_stats,
+                              struct rtnl_link_stats64 *core_stats);
        void (*start_stats)(struct efx_nic *efx);
        void (*stop_stats)(struct efx_nic *efx);
        void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode);
@@ -1135,7 +1090,7 @@ struct efx_nic_type {
        void (*rx_write)(struct efx_rx_queue *rx_queue);
        void (*rx_defer_refill)(struct efx_rx_queue *rx_queue);
        int (*ev_probe)(struct efx_channel *channel);
-       void (*ev_init)(struct efx_channel *channel);
+       int (*ev_init)(struct efx_channel *channel);
        void (*ev_fini)(struct efx_channel *channel);
        void (*ev_remove)(struct efx_channel *channel);
        int (*ev_process)(struct efx_channel *channel, int quota);
@@ -1177,6 +1132,7 @@ struct efx_nic_type {
                         size_t *retlen, const u8 *buffer);
        int (*mtd_sync)(struct mtd_info *mtd);
 #endif
+       void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
 
        int revision;
        unsigned int txd_ptr_tbl_base;
@@ -1185,9 +1141,11 @@ struct efx_nic_type {
        unsigned int evq_ptr_tbl_base;
        unsigned int evq_rptr_tbl_base;
        u64 max_dma_mask;
-       unsigned int rx_buffer_hash_size;
+       unsigned int rx_prefix_size;
+       unsigned int rx_hash_offset;
        unsigned int rx_buffer_padding;
        bool can_rx_scatter;
+       bool always_rx_scatter;
        unsigned int max_interrupt_mode;
        unsigned int timer_period_max;
        netdev_features_t offload_features;