aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/gianfar.h
diff options
context:
space:
mode:
authorSandeep Gopalpet <Sandeep.Kumar@freescale.com>2009-11-02 02:03:15 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-03 02:40:57 -0500
commitfba4ed030cfae7efdb6b79a57b0c5a9d72c9de83 (patch)
treeddee54010c64517a01ea112ca16e5bc1fee0938c /drivers/net/gianfar.h
parentf4983704a63b3764418905a77d48105a8cbce97f (diff)
gianfar: Add Multiple Queue Support
This patch introduces multiple Tx and Rx queues. The incoming packets can be classified into different queues based on filer rules (out of scope of this patch). The number of queues enabled will be based on a DTS entries fsl,num_tx_queues and fsl,num_rx_queues. Although we are enabling multiple queues, the interrupt coalescing is on per device level (etsec-1.7 doesn't support multiple rxics and txics). Signed-off-by: Sandeep Gopalpet <Sandeep.Kumar@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/gianfar.h')
-rw-r--r--drivers/net/gianfar.h96
1 files changed, 91 insertions, 5 deletions
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 79e8471584ea..5ae769df1d81 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -75,6 +75,10 @@
75extern const char gfar_driver_name[]; 75extern const char gfar_driver_name[];
76extern const char gfar_driver_version[]; 76extern const char gfar_driver_version[];
77 77
78/* MAXIMUM NUMBER OF QUEUES SUPPORTED */
79#define MAX_TX_QS 0x8
80#define MAX_RX_QS 0x8
81
78/* These need to be powers of 2 for this driver */ 82/* These need to be powers of 2 for this driver */
79#define DEFAULT_TX_RING_SIZE 256 83#define DEFAULT_TX_RING_SIZE 256
80#define DEFAULT_RX_RING_SIZE 256 84#define DEFAULT_RX_RING_SIZE 256
@@ -172,12 +176,63 @@ extern const char gfar_driver_version[];
172 176
173#define MINFLR_INIT_SETTINGS 0x00000040 177#define MINFLR_INIT_SETTINGS 0x00000040
174 178
179/* Tqueue control */
180#define TQUEUE_EN0 0x00008000
181#define TQUEUE_EN1 0x00004000
182#define TQUEUE_EN2 0x00002000
183#define TQUEUE_EN3 0x00001000
184#define TQUEUE_EN4 0x00000800
185#define TQUEUE_EN5 0x00000400
186#define TQUEUE_EN6 0x00000200
187#define TQUEUE_EN7 0x00000100
188#define TQUEUE_EN_ALL 0x0000FF00
189
190#define TR03WT_WT0_MASK 0xFF000000
191#define TR03WT_WT1_MASK 0x00FF0000
192#define TR03WT_WT2_MASK 0x0000FF00
193#define TR03WT_WT3_MASK 0x000000FF
194
195#define TR47WT_WT4_MASK 0xFF000000
196#define TR47WT_WT5_MASK 0x00FF0000
197#define TR47WT_WT6_MASK 0x0000FF00
198#define TR47WT_WT7_MASK 0x000000FF
199
200/* Rqueue control */
201#define RQUEUE_EX0 0x00800000
202#define RQUEUE_EX1 0x00400000
203#define RQUEUE_EX2 0x00200000
204#define RQUEUE_EX3 0x00100000
205#define RQUEUE_EX4 0x00080000
206#define RQUEUE_EX5 0x00040000
207#define RQUEUE_EX6 0x00020000
208#define RQUEUE_EX7 0x00010000
209#define RQUEUE_EX_ALL 0x00FF0000
210
211#define RQUEUE_EN0 0x00000080
212#define RQUEUE_EN1 0x00000040
213#define RQUEUE_EN2 0x00000020
214#define RQUEUE_EN3 0x00000010
215#define RQUEUE_EN4 0x00000008
216#define RQUEUE_EN5 0x00000004
217#define RQUEUE_EN6 0x00000002
218#define RQUEUE_EN7 0x00000001
219#define RQUEUE_EN_ALL 0x000000FF
220
175/* Init to do tx snooping for buffers and descriptors */ 221/* Init to do tx snooping for buffers and descriptors */
176#define DMACTRL_INIT_SETTINGS 0x000000c3 222#define DMACTRL_INIT_SETTINGS 0x000000c3
177#define DMACTRL_GRS 0x00000010 223#define DMACTRL_GRS 0x00000010
178#define DMACTRL_GTS 0x00000008 224#define DMACTRL_GTS 0x00000008
179 225
180#define TSTAT_CLEAR_THALT 0x80000000 226#define TSTAT_CLEAR_THALT_ALL 0xFF000000
227#define TSTAT_CLEAR_THALT 0x80000000
228#define TSTAT_CLEAR_THALT0 0x80000000
229#define TSTAT_CLEAR_THALT1 0x40000000
230#define TSTAT_CLEAR_THALT2 0x20000000
231#define TSTAT_CLEAR_THALT3 0x10000000
232#define TSTAT_CLEAR_THALT4 0x08000000
233#define TSTAT_CLEAR_THALT5 0x04000000
234#define TSTAT_CLEAR_THALT6 0x02000000
235#define TSTAT_CLEAR_THALT7 0x01000000
181 236
182/* Interrupt coalescing macros */ 237/* Interrupt coalescing macros */
183#define IC_ICEN 0x80000000 238#define IC_ICEN 0x80000000
@@ -228,6 +283,13 @@ extern const char gfar_driver_version[];
228#define TCTRL_IPCSEN 0x00004000 283#define TCTRL_IPCSEN 0x00004000
229#define TCTRL_TUCSEN 0x00002000 284#define TCTRL_TUCSEN 0x00002000
230#define TCTRL_VLINS 0x00001000 285#define TCTRL_VLINS 0x00001000
286#define TCTRL_THDF 0x00000800
287#define TCTRL_RFCPAUSE 0x00000010
288#define TCTRL_TFCPAUSE 0x00000008
289#define TCTRL_TXSCHED_MASK 0x00000006
290#define TCTRL_TXSCHED_INIT 0x00000000
291#define TCTRL_TXSCHED_PRIO 0x00000002
292#define TCTRL_TXSCHED_WRRS 0x00000004
231#define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN) 293#define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN)
232 294
233#define IEVENT_INIT_CLEAR 0xffffffff 295#define IEVENT_INIT_CLEAR 0xffffffff
@@ -700,6 +762,8 @@ struct gfar {
700#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200 762#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200
701#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400 763#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400
702 764
765#define DEFAULT_MAPPING 0xFF
766
703/** 767/**
704 * struct gfar_priv_tx_q - per tx queue structure 768 * struct gfar_priv_tx_q - per tx queue structure
705 * @txlock: per queue tx spin lock 769 * @txlock: per queue tx spin lock
@@ -743,7 +807,6 @@ struct gfar_priv_tx_q {
743/** 807/**
744 * struct gfar_priv_rx_q - per rx queue structure 808 * struct gfar_priv_rx_q - per rx queue structure
745 * @rxlock: per queue rx spin lock 809 * @rxlock: per queue rx spin lock
746 * @napi: the napi poll function
747 * @rx_skbuff: skb pointers 810 * @rx_skbuff: skb pointers
748 * @skb_currx: currently use skb pointer 811 * @skb_currx: currently use skb pointer
749 * @rx_bd_base: First rx buffer descriptor 812 * @rx_bd_base: First rx buffer descriptor
@@ -757,8 +820,8 @@ struct gfar_priv_tx_q {
757 820
758struct gfar_priv_rx_q { 821struct gfar_priv_rx_q {
759 spinlock_t rxlock __attribute__ ((aligned (SMP_CACHE_BYTES))); 822 spinlock_t rxlock __attribute__ ((aligned (SMP_CACHE_BYTES)));
760 struct napi_struct napi;
761 struct sk_buff ** rx_skbuff; 823 struct sk_buff ** rx_skbuff;
824 dma_addr_t rx_bd_dma_base;
762 struct rxbd8 *rx_bd_base; 825 struct rxbd8 *rx_bd_base;
763 struct rxbd8 *cur_rx; 826 struct rxbd8 *cur_rx;
764 struct net_device *dev; 827 struct net_device *dev;
@@ -772,6 +835,7 @@ struct gfar_priv_rx_q {
772 835
773/** 836/**
774 * struct gfar_priv_grp - per group structure 837 * struct gfar_priv_grp - per group structure
838 * @napi: the napi poll function
775 * @priv: back pointer to the priv structure 839 * @priv: back pointer to the priv structure
776 * @regs: the ioremapped register space for this group 840 * @regs: the ioremapped register space for this group
777 * @grp_id: group id for this group 841 * @grp_id: group id for this group
@@ -785,8 +849,17 @@ struct gfar_priv_rx_q {
785 849
786struct gfar_priv_grp { 850struct gfar_priv_grp {
787 spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES))); 851 spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES)));
852 struct napi_struct napi;
788 struct gfar_private *priv; 853 struct gfar_private *priv;
789 struct gfar __iomem *regs; 854 struct gfar __iomem *regs;
855 unsigned int rx_bit_map;
856 unsigned int tx_bit_map;
857 unsigned int num_tx_queues;
858 unsigned int num_rx_queues;
859 unsigned int rstat;
860 unsigned int tstat;
861 unsigned int imask;
862 unsigned int ievent;
790 unsigned int interruptTransmit; 863 unsigned int interruptTransmit;
791 unsigned int interruptReceive; 864 unsigned int interruptReceive;
792 unsigned int interruptError; 865 unsigned int interruptError;
@@ -807,13 +880,21 @@ struct gfar_priv_grp {
807 */ 880 */
808struct gfar_private { 881struct gfar_private {
809 882
883 /* Indicates how many tx, rx queues are enabled */
884 unsigned int num_tx_queues;
885 unsigned int num_rx_queues;
886
887 /* The total tx and rx ring size for the enabled queues */
888 unsigned int total_tx_ring_size;
889 unsigned int total_rx_ring_size;
890
810 struct device_node *node; 891 struct device_node *node;
811 struct net_device *ndev; 892 struct net_device *ndev;
812 struct of_device *ofdev; 893 struct of_device *ofdev;
813 894
814 struct gfar_priv_grp gfargrp; 895 struct gfar_priv_grp gfargrp;
815 struct gfar_priv_tx_q *tx_queue; 896 struct gfar_priv_tx_q *tx_queue[MAX_TX_QS];
816 struct gfar_priv_rx_q *rx_queue; 897 struct gfar_priv_rx_q *rx_queue[MAX_RX_QS];
817 898
818 /* RX per device parameters */ 899 /* RX per device parameters */
819 unsigned int rx_buffer_size; 900 unsigned int rx_buffer_size;
@@ -844,6 +925,7 @@ struct gfar_private {
844 unsigned char rx_csum_enable:1, 925 unsigned char rx_csum_enable:1,
845 extended_hash:1, 926 extended_hash:1,
846 bd_stash_en:1, 927 bd_stash_en:1,
928 rx_filer_enable:1,
847 wol_en:1; /* Wake-on-LAN enabled */ 929 wol_en:1; /* Wake-on-LAN enabled */
848 unsigned short padding; 930 unsigned short padding;
849 931
@@ -874,6 +956,10 @@ static inline void gfar_write(volatile unsigned __iomem *addr, u32 val)
874 out_be32(addr, val); 956 out_be32(addr, val);
875} 957}
876 958
959extern void lock_rx_qs(struct gfar_private *priv);
960extern void lock_tx_qs(struct gfar_private *priv);
961extern void unlock_rx_qs(struct gfar_private *priv);
962extern void unlock_tx_qs(struct gfar_private *priv);
877extern irqreturn_t gfar_receive(int irq, void *dev_id); 963extern irqreturn_t gfar_receive(int irq, void *dev_id);
878extern int startup_gfar(struct net_device *dev); 964extern int startup_gfar(struct net_device *dev);
879extern void stop_gfar(struct net_device *dev); 965extern void stop_gfar(struct net_device *dev);