Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / drivers / net / ethernet / amd / xgbe / xgbe.h
index d3aa055..f9ec762 100644 (file)
 
 #define XGBE_TX_MAX_BUF_SIZE   (0x3fff & ~(64 - 1))
 
+/* Descriptors required for maximum contigous TSO/GSO packet */
+#define XGBE_TX_MAX_SPLIT      ((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
+
+/* Maximum possible descriptors needed for an SKB:
+ * - Maximum number of SKB frags
+ * - Maximum descriptors for contiguous TSO/GSO packet
+ * - Possible context descriptor
+ * - Possible TSO header descriptor
+ */
+#define XGBE_TX_MAX_DESCS      (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
+
 #define XGBE_RX_MIN_BUF_SIZE   (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
 #define XGBE_RX_BUF_ALIGN      64
 #define XGBE_SKB_ALLOC_SIZE    256
+#define XGBE_SPH_HDSMS_SIZE    2       /* Keep in sync with SKB_ALLOC_SIZE */
 
 #define XGBE_MAX_DMA_CHANNELS  16
 #define XGBE_MAX_QUEUES                16
+#define XGBE_DMA_STOP_TIMEOUT  5
 
 /* DMA cache settings - Outer sharable, write-back, write-allocate */
 #define XGBE_DMA_OS_AXDOMAIN   0x2
 /* Device-tree clock names */
 #define XGBE_DMA_CLOCK         "dma_clk"
 #define XGBE_PTP_CLOCK         "ptp_clk"
+#define XGBE_DMA_IRQS          "amd,per-channel-interrupt"
 
 /* Timestamp support - values based on 50MHz PTP clock
  *   50MHz => 20 nsec
 /* Maximum MAC address hash table size (256 bits = 8 bytes) */
 #define XGBE_MAC_HASH_TABLE_SIZE       8
 
+/* Receive Side Scaling */
+#define XGBE_RSS_HASH_KEY_SIZE         40
+#define XGBE_RSS_MAX_TABLE_SIZE                256
+#define XGBE_RSS_LOOKUP_TABLE_TYPE     0
+#define XGBE_RSS_HASH_KEY_TYPE         1
+
 struct xgbe_prv_data;
 
 struct xgbe_packet_data {
+       struct sk_buff *skb;
+
        unsigned int attributes;
 
        unsigned int errors;
@@ -231,14 +253,20 @@ struct xgbe_packet_data {
        unsigned short vlan_ctag;
 
        u64 rx_tstamp;
+
+       u32 rss_hash;
+       enum pkt_hash_types rss_hash_type;
+
+       unsigned int tx_packets;
+       unsigned int tx_bytes;
 };
 
 /* Common Rx and Tx descriptor mapping */
 struct xgbe_ring_desc {
-       u32 desc0;
-       u32 desc1;
-       u32 desc2;
-       u32 desc3;
+       __le32 desc0;
+       __le32 desc1;
+       __le32 desc2;
+       __le32 desc3;
 };
 
 /* Page allocation related values */
@@ -250,6 +278,30 @@ struct xgbe_page_alloc {
        dma_addr_t pages_dma;
 };
 
+/* Ring entry buffer data */
+struct xgbe_buffer_data {
+       struct xgbe_page_alloc pa;
+       struct xgbe_page_alloc pa_unmap;
+
+       dma_addr_t dma;
+       unsigned int dma_len;
+};
+
+/* Tx-related ring data */
+struct xgbe_tx_ring_data {
+       unsigned int packets;           /* BQL packet count */
+       unsigned int bytes;             /* BQL byte count */
+};
+
+/* Rx-related ring data */
+struct xgbe_rx_ring_data {
+       struct xgbe_buffer_data hdr;    /* Header locations */
+       struct xgbe_buffer_data buf;    /* Payload locations */
+
+       unsigned short hdr_len;         /* Length of received header */
+       unsigned short len;             /* Length of received packet */
+};
+
 /* Structure used to hold information related to the descriptor
  * and the packet associated with the descriptor (always use
  * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
@@ -261,15 +313,9 @@ struct xgbe_ring_data {
        struct sk_buff *skb;            /* Virtual address of SKB */
        dma_addr_t skb_dma;             /* DMA address of SKB data */
        unsigned int skb_dma_len;       /* Length of SKB DMA area */
-       unsigned int tso_header;        /* TSO header indicator */
-
-       struct xgbe_page_alloc rx_pa;   /* Rx buffer page allocation */
-       struct xgbe_page_alloc rx_unmap;
 
-       dma_addr_t rx_dma;              /* DMA address of Rx buffer */
-       unsigned int rx_dma_len;        /* Length of the Rx DMA buffer */
-
-       unsigned short len;             /* Length of received Rx packet */
+       struct xgbe_tx_ring_data tx;    /* Tx-related data */
+       struct xgbe_rx_ring_data rx;    /* Rx-related data */
 
        unsigned int interrupt;         /* Interrupt indicator */
 
@@ -308,7 +354,8 @@ struct xgbe_ring {
        struct xgbe_ring_data *rdata;
 
        /* Page allocation for RX buffers */
-       struct xgbe_page_alloc rx_pa;
+       struct xgbe_page_alloc rx_hdr_pa;
+       struct xgbe_page_alloc rx_buf_pa;
 
        /* Ring index values
         *  cur   - Tx: index of descriptor to be used for current transfer
@@ -326,6 +373,7 @@ struct xgbe_ring {
        union {
                struct {
                        unsigned int queue_stopped;
+                       unsigned int xmit_more;
                        unsigned short cur_mss;
                        unsigned short cur_vlan_ctag;
                } tx;
@@ -350,6 +398,13 @@ struct xgbe_channel {
        unsigned int queue_index;
        void __iomem *dma_regs;
 
+       /* Per channel interrupt irq number */
+       int dma_irq;
+       char dma_irq_name[IFNAMSIZ + 32];
+
+       /* Netdev related settings */
+       struct napi_struct napi;
+
        unsigned int saved_ier;
 
        unsigned int tx_timer_active;
@@ -483,6 +538,7 @@ struct xgbe_hw_if {
        void (*tx_desc_reset)(struct xgbe_ring_data *);
        int (*is_last_desc)(struct xgbe_ring_desc *);
        int (*is_context_desc)(struct xgbe_ring_desc *);
+       void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
 
        /* For FLOW ctrl */
        int (*config_tx_flow_control)(struct xgbe_prv_data *);
@@ -528,6 +584,12 @@ struct xgbe_hw_if {
        /* For Data Center Bridging config */
        void (*config_dcb_tc)(struct xgbe_prv_data *);
        void (*config_dcb_pfc)(struct xgbe_prv_data *);
+
+       /* For Receive Side Scaling */
+       int (*enable_rss)(struct xgbe_prv_data *);
+       int (*disable_rss)(struct xgbe_prv_data *);
+       int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
+       int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
 };
 
 struct xgbe_desc_if {
@@ -600,7 +662,11 @@ struct xgbe_prv_data {
        /* XPCS indirect addressing mutex */
        struct mutex xpcs_mutex;
 
-       int irq_number;
+       /* RSS addressing mutex */
+       struct mutex rss_mutex;
+
+       int dev_irq;
+       unsigned int per_channel_irq;
 
        struct xgbe_hw_if hw_if;
        struct xgbe_desc_if desc_if;
@@ -651,6 +717,11 @@ struct xgbe_prv_data {
        unsigned int tx_pause;
        unsigned int rx_pause;
 
+       /* Receive Side Scaling settings */
+       u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
+       u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
+       u32 rss_options;
+
        /* MDIO settings */
        struct module *phy_module;
        char *mii_bus_id;