aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale/gianfar.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/freescale/gianfar.h')
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h114
1 files changed, 80 insertions, 34 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 52bb2b0195cc..84632c569f2c 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -9,7 +9,7 @@
9 * Maintainer: Kumar Gala 9 * Maintainer: Kumar Gala
10 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> 10 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com>
11 * 11 *
12 * Copyright 2002-2009, 2011 Freescale Semiconductor, Inc. 12 * Copyright 2002-2009, 2011-2013 Freescale Semiconductor, Inc.
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
@@ -377,8 +377,11 @@ extern const char gfar_driver_version[];
377 IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \ 377 IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \
378 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ 378 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \
379 | IMASK_PERR) 379 | IMASK_PERR)
380#define IMASK_RTX_DISABLED ((~(IMASK_RXFEN0 | IMASK_TXFEN | IMASK_BSY)) \ 380#define IMASK_RX_DEFAULT (IMASK_RXFEN0 | IMASK_BSY)
381 & IMASK_DEFAULT) 381#define IMASK_TX_DEFAULT (IMASK_TXFEN | IMASK_TXBEN)
382
383#define IMASK_RX_DISABLED ((~(IMASK_RX_DEFAULT)) & IMASK_DEFAULT)
384#define IMASK_TX_DISABLED ((~(IMASK_TX_DEFAULT)) & IMASK_DEFAULT)
382 385
383/* Fifo management */ 386/* Fifo management */
384#define FIFO_TX_THR_MASK 0x01ff 387#define FIFO_TX_THR_MASK 0x01ff
@@ -409,7 +412,9 @@ extern const char gfar_driver_version[];
409 412
410/* This default RIR value directly corresponds 413/* This default RIR value directly corresponds
411 * to the 3-bit hash value generated */ 414 * to the 3-bit hash value generated */
412#define DEFAULT_RIR0 0x05397700 415#define DEFAULT_8RXQ_RIR0 0x05397700
416/* Map even hash values to Q0, and odd ones to Q1 */
417#define DEFAULT_2RXQ_RIR0 0x04104100
413 418
414/* RQFCR register bits */ 419/* RQFCR register bits */
415#define RQFCR_GPI 0x80000000 420#define RQFCR_GPI 0x80000000
@@ -880,7 +885,6 @@ struct gfar {
880#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010 885#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
881#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020 886#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
882#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040 887#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
883#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
884#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100 888#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
885#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200 889#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200
886#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400 890#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400
@@ -892,8 +896,8 @@ struct gfar {
892#define DEFAULT_MAPPING 0xFF 896#define DEFAULT_MAPPING 0xFF
893#endif 897#endif
894 898
895#define ISRG_SHIFT_TX 0x10 899#define ISRG_RR0 0x80000000
896#define ISRG_SHIFT_RX 0x18 900#define ISRG_TR0 0x00800000
897 901
898/* The same driver can operate in two modes */ 902/* The same driver can operate in two modes */
899/* SQ_SG_MODE: Single Queue Single Group Mode 903/* SQ_SG_MODE: Single Queue Single Group Mode
@@ -905,6 +909,22 @@ enum {
905 MQ_MG_MODE 909 MQ_MG_MODE
906}; 910};
907 911
912/* GFAR_SQ_POLLING: Single Queue NAPI polling mode
913 * The driver supports a single pair of RX/Tx queues
914 * per interrupt group (Rx/Tx int line). MQ_MG mode
915 * devices have 2 interrupt groups, so the device will
916 * have a total of 2 Tx and 2 Rx queues in this case.
917 * GFAR_MQ_POLLING: Multi Queue NAPI polling mode
918 * The driver supports all the 8 Rx and Tx HW queues
919 * each queue mapped by the Device Tree to one of
920 * the 2 interrupt groups. This mode implies significant
921 * processing overhead (CPU and controller level).
922 */
923enum gfar_poll_mode {
924 GFAR_SQ_POLLING = 0,
925 GFAR_MQ_POLLING
926};
927
908/* 928/*
909 * Per TX queue stats 929 * Per TX queue stats
910 */ 930 */
@@ -966,7 +986,6 @@ struct rx_q_stats {
966 986
967/** 987/**
968 * struct gfar_priv_rx_q - per rx queue structure 988 * struct gfar_priv_rx_q - per rx queue structure
969 * @rxlock: per queue rx spin lock
970 * @rx_skbuff: skb pointers 989 * @rx_skbuff: skb pointers
971 * @skb_currx: currently use skb pointer 990 * @skb_currx: currently use skb pointer
972 * @rx_bd_base: First rx buffer descriptor 991 * @rx_bd_base: First rx buffer descriptor
@@ -979,8 +998,7 @@ struct rx_q_stats {
979 */ 998 */
980 999
981struct gfar_priv_rx_q { 1000struct gfar_priv_rx_q {
982 spinlock_t rxlock __attribute__ ((aligned (SMP_CACHE_BYTES))); 1001 struct sk_buff **rx_skbuff __aligned(SMP_CACHE_BYTES);
983 struct sk_buff ** rx_skbuff;
984 dma_addr_t rx_bd_dma_base; 1002 dma_addr_t rx_bd_dma_base;
985 struct rxbd8 *rx_bd_base; 1003 struct rxbd8 *rx_bd_base;
986 struct rxbd8 *cur_rx; 1004 struct rxbd8 *cur_rx;
@@ -1016,17 +1034,20 @@ struct gfar_irqinfo {
1016 */ 1034 */
1017 1035
1018struct gfar_priv_grp { 1036struct gfar_priv_grp {
1019 spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES))); 1037 spinlock_t grplock __aligned(SMP_CACHE_BYTES);
1020 struct napi_struct napi; 1038 struct napi_struct napi_rx;
1021 struct gfar_private *priv; 1039 struct napi_struct napi_tx;
1022 struct gfar __iomem *regs; 1040 struct gfar __iomem *regs;
1023 unsigned int rstat; 1041 struct gfar_priv_tx_q *tx_queue;
1024 unsigned long num_rx_queues; 1042 struct gfar_priv_rx_q *rx_queue;
1025 unsigned long rx_bit_map;
1026 /* cacheline 3 */
1027 unsigned int tstat; 1043 unsigned int tstat;
1044 unsigned int rstat;
1045
1046 struct gfar_private *priv;
1028 unsigned long num_tx_queues; 1047 unsigned long num_tx_queues;
1029 unsigned long tx_bit_map; 1048 unsigned long tx_bit_map;
1049 unsigned long num_rx_queues;
1050 unsigned long rx_bit_map;
1030 1051
1031 struct gfar_irqinfo *irqinfo[GFAR_NUM_IRQS]; 1052 struct gfar_irqinfo *irqinfo[GFAR_NUM_IRQS];
1032}; 1053};
@@ -1041,6 +1062,11 @@ enum gfar_errata {
1041 GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */ 1062 GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */
1042}; 1063};
1043 1064
1065enum gfar_dev_state {
1066 GFAR_DOWN = 1,
1067 GFAR_RESETTING
1068};
1069
1044/* Struct stolen almost completely (and shamelessly) from the FCC enet source 1070/* Struct stolen almost completely (and shamelessly) from the FCC enet source
1045 * (Ok, that's not so true anymore, but there is a family resemblance) 1071 * (Ok, that's not so true anymore, but there is a family resemblance)
1046 * The GFAR buffer descriptors track the ring buffers. The rx_bd_base 1072 * The GFAR buffer descriptors track the ring buffers. The rx_bd_base
@@ -1051,8 +1077,6 @@ enum gfar_errata {
1051 * the buffer descriptor determines the actual condition. 1077 * the buffer descriptor determines the actual condition.
1052 */ 1078 */
1053struct gfar_private { 1079struct gfar_private {
1054 unsigned int num_rx_queues;
1055
1056 struct device *dev; 1080 struct device *dev;
1057 struct net_device *ndev; 1081 struct net_device *ndev;
1058 enum gfar_errata errata; 1082 enum gfar_errata errata;
@@ -1060,6 +1084,7 @@ struct gfar_private {
1060 1084
1061 u16 uses_rxfcb; 1085 u16 uses_rxfcb;
1062 u16 padding; 1086 u16 padding;
1087 u32 device_flags;
1063 1088
1064 /* HW time stamping enabled flag */ 1089 /* HW time stamping enabled flag */
1065 int hwts_rx_en; 1090 int hwts_rx_en;
@@ -1069,10 +1094,12 @@ struct gfar_private {
1069 struct gfar_priv_rx_q *rx_queue[MAX_RX_QS]; 1094 struct gfar_priv_rx_q *rx_queue[MAX_RX_QS];
1070 struct gfar_priv_grp gfargrp[MAXGROUPS]; 1095 struct gfar_priv_grp gfargrp[MAXGROUPS];
1071 1096
1072 u32 device_flags; 1097 unsigned long state;
1073 1098
1074 unsigned int mode; 1099 unsigned short mode;
1100 unsigned short poll_mode;
1075 unsigned int num_tx_queues; 1101 unsigned int num_tx_queues;
1102 unsigned int num_rx_queues;
1076 unsigned int num_grps; 1103 unsigned int num_grps;
1077 1104
1078 /* Network Statistics */ 1105 /* Network Statistics */
@@ -1113,6 +1140,9 @@ struct gfar_private {
1113 unsigned int total_tx_ring_size; 1140 unsigned int total_tx_ring_size;
1114 unsigned int total_rx_ring_size; 1141 unsigned int total_rx_ring_size;
1115 1142
1143 u32 rqueue;
1144 u32 tqueue;
1145
1116 /* RX per device parameters */ 1146 /* RX per device parameters */
1117 unsigned int rx_stash_size; 1147 unsigned int rx_stash_size;
1118 unsigned int rx_stash_index; 1148 unsigned int rx_stash_index;
@@ -1127,11 +1157,6 @@ struct gfar_private {
1127 u32 __iomem *hash_regs[16]; 1157 u32 __iomem *hash_regs[16];
1128 int hash_width; 1158 int hash_width;
1129 1159
1130 /* global parameters */
1131 unsigned int fifo_threshold;
1132 unsigned int fifo_starve;
1133 unsigned int fifo_starve_off;
1134
1135 /*Filer table*/ 1160 /*Filer table*/
1136 unsigned int ftp_rqfpr[MAX_FILER_IDX + 1]; 1161 unsigned int ftp_rqfpr[MAX_FILER_IDX + 1];
1137 unsigned int ftp_rqfcr[MAX_FILER_IDX + 1]; 1162 unsigned int ftp_rqfcr[MAX_FILER_IDX + 1];
@@ -1176,21 +1201,42 @@ static inline void gfar_read_filer(struct gfar_private *priv,
1176 *fpr = gfar_read(&regs->rqfpr); 1201 *fpr = gfar_read(&regs->rqfpr);
1177} 1202}
1178 1203
1179void lock_rx_qs(struct gfar_private *priv); 1204static inline void gfar_write_isrg(struct gfar_private *priv)
1180void lock_tx_qs(struct gfar_private *priv); 1205{
1181void unlock_rx_qs(struct gfar_private *priv); 1206 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1182void unlock_tx_qs(struct gfar_private *priv); 1207 u32 __iomem *baddr = &regs->isrg0;
1208 u32 isrg = 0;
1209 int grp_idx, i;
1210
1211 for (grp_idx = 0; grp_idx < priv->num_grps; grp_idx++) {
1212 struct gfar_priv_grp *grp = &priv->gfargrp[grp_idx];
1213
1214 for_each_set_bit(i, &grp->rx_bit_map, priv->num_rx_queues) {
1215 isrg |= (ISRG_RR0 >> i);
1216 }
1217
1218 for_each_set_bit(i, &grp->tx_bit_map, priv->num_tx_queues) {
1219 isrg |= (ISRG_TR0 >> i);
1220 }
1221
1222 gfar_write(baddr, isrg);
1223
1224 baddr++;
1225 isrg = 0;
1226 }
1227}
1228
1183irqreturn_t gfar_receive(int irq, void *dev_id); 1229irqreturn_t gfar_receive(int irq, void *dev_id);
1184int startup_gfar(struct net_device *dev); 1230int startup_gfar(struct net_device *dev);
1185void stop_gfar(struct net_device *dev); 1231void stop_gfar(struct net_device *dev);
1186void gfar_halt(struct net_device *dev); 1232void reset_gfar(struct net_device *dev);
1233void gfar_mac_reset(struct gfar_private *priv);
1234void gfar_halt(struct gfar_private *priv);
1235void gfar_start(struct gfar_private *priv);
1187void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, int enable, 1236void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, int enable,
1188 u32 regnum, u32 read); 1237 u32 regnum, u32 read);
1189void gfar_configure_coalescing_all(struct gfar_private *priv); 1238void gfar_configure_coalescing_all(struct gfar_private *priv);
1190void gfar_init_sysfs(struct net_device *dev);
1191int gfar_set_features(struct net_device *dev, netdev_features_t features); 1239int gfar_set_features(struct net_device *dev, netdev_features_t features);
1192void gfar_check_rx_parser_mode(struct gfar_private *priv);
1193void gfar_vlan_mode(struct net_device *dev, netdev_features_t features);
1194 1240
1195extern const struct ethtool_ops gfar_ethtool_ops; 1241extern const struct ethtool_ops gfar_ethtool_ops;
1196 1242