#include <linux/version.h>
#define DRV_NAME "jme"
-#define DRV_VERSION "0.5"
+#define DRV_VERSION "0.8"
#define PFX DRV_NAME ": "
#ifdef DEBUG
#define rx_dbg(args...)
#endif
+#ifdef QUEUE_DEBUG
+#define queue_dbg(devname, fmt, args...) dprintk(devname, fmt, ## args)
+#else
+#define queue_dbg(args...)
+#endif
+
+#ifdef CSUM_DEBUG
+#define csum_dbg(devname, fmt, args...) dprintk(devname, fmt, ## args)
+#else
+#define csum_dbg(args...)
+#endif
+
#define jprintk(devname, fmt, args...) \
printk(KERN_INFO "%s: " fmt, devname, ## args)
#define jeprintk(devname, fmt, args...) \
printk(KERN_ERR "%s: " fmt, devname, ## args)
-#define USE_IEVE_SHADOW 0
-
#define DEFAULT_MSG_ENABLE \
(NETIF_MSG_DRV | \
NETIF_MSG_PROBE | \
MRRS_4096B = 0x50,
};
+#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9216
+#define MIN_ETHERNET_PACKET_SIZE 60
+
enum dynamic_pcc_values {
PCC_P1 = 1,
PCC_P2 = 2,
PCC_P3_CNT = 255,
};
struct dynpcc_info {
- unsigned long check_point;
unsigned long last_bytes;
unsigned long last_pkts;
+ unsigned long intr_cnt;
unsigned char cur;
unsigned char attempt;
unsigned char cnt;
};
-#define PCC_INTERVAL (HZ / 10)
+#define PCC_INTERVAL_US 100000
+#define PCC_INTERVAL (HZ / (1000000/PCC_INTERVAL_US))
#define PCC_P3_THRESHOLD 3*1024*1024
-#define PCC_P2_THRESHOLD 1000
-#define PCC_TX_TO 60000
-#define PCC_TX_CNT 8
+#define PCC_P2_THRESHOLD 800
+#define PCC_INTR_THRESHOLD 800
+#define PCC_TX_TO 100
+#define PCC_TX_CNT 16
/*
* TX/RX Descriptors
#define RX_RING_SIZE (RING_DESC_NR * RX_DESC_SIZE)
#define RX_BUF_DMA_ALIGN 8
-#define RX_BUF_SIZE 9216
#define RX_PREPAD_SIZE 10
-
-/*
- * Will use mtu in the future
- */
-#define RX_BUF_ALLOC_SIZE RX_BUF_SIZE + RX_BUF_DMA_ALIGN
+#define ETH_CRC_LEN 2
+#define RX_VLANHDR_LEN 2
+#define RX_EXTRA_LEN (RX_PREPAD_SIZE + \
+ ETH_HLEN + \
+ ETH_CRC_LEN + \
+ RX_VLANHDR_LEN + \
+ RX_BUF_DMA_ALIGN)
struct rxdesc {
union {
u16 next_to_use;
u16 next_to_clean;
- u16 nr_free;
+ atomic_t nr_free;
};
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
struct mii_if_info mii_if;
struct jme_ring rxring[RX_RING_NR];
struct jme_ring txring[TX_RING_NR];
- spinlock_t tx_lock;
spinlock_t phy_lock;
spinlock_t macaddr_lock;
spinlock_t rxmcs_lock;
struct tasklet_struct rxclean_task;
struct tasklet_struct txclean_task;
struct tasklet_struct linkch_task;
- __u32 features;
+ struct tasklet_struct pcc_task;
+ __u32 flags;
__u32 reg_txcs;
__u32 reg_txpfc;
+ __u32 reg_rxcs;
__u32 reg_rxmcs;
__u32 reg_ghc;
+ __u32 reg_pmcs;
__u32 phylink;
__u8 mrrs;
+ struct ethtool_cmd old_ecmd;
+ unsigned int old_mtu;
+ struct vlan_group* vlgrp;
struct dynpcc_info dpi;
atomic_t intr_sem;
atomic_t link_changing;
enum shadow_reg_val {
SHADOW_IEVE = 0,
};
-enum jme_features_bits {
- JME_FEATURE_LALALA = 0x00000001,
+enum jme_flags_bits {
+ JME_FLAG_MSI = 0x00000001,
+ JME_FLAG_SSET = 0x00000002,
};
#define WAIT_TASKLET_TIMEOUT 500 /* 500 ms */
#define TX_TIMEOUT (5*HZ)
JME_SMBCSR = JME_PHY | 0x40, /* SMB Control and Status */
+ JME_TMCSR = JME_MISC| 0x00, /* Timer Control/Status Register */
JME_GPREG0 = JME_MISC| 0x08, /* General purpose REG-0 */
JME_GPREG1 = JME_MISC| 0x0C, /* General purpose REG-1 */
JME_IEVE = JME_MISC| 0x20, /* Interrupt Event Status */
TXCS_DEFAULT = TXCS_FIFOTH_4QW |
TXCS_BURST,
};
-#define JME_TX_DISABLE_TIMEOUT 5 /* 5 msec */
+#define JME_TX_DISABLE_TIMEOUT 10 /* 10 msec */
/*
* TX MAC Control/Status Bits
RXCS_RETRYCNT_60 = 0x00000F00,
RXCS_DEFAULT = RXCS_FIFOTHTP_128T |
- //RXCS_FIFOTHNP_128QW |
- RXCS_FIFOTHNP_32QW |
+ RXCS_FIFOTHNP_128QW |
RXCS_DMAREQSZ_128B |
RXCS_RETRYGAP_256ns |
RXCS_RETRYCNT_32,
};
-#define JME_RX_DISABLE_TIMEOUT 5 /* 5 msec */
+#define JME_RX_DISABLE_TIMEOUT 10 /* 10 msec */
/*
* RX MAC Control/Status Bits
GHC_SPEED_1000M = 0x00000030,
};
+/*
+ * Power management control and status register
+ */
+enum jme_pmcs_bit_masks {
+ PMCS_WF7DET = 0x80000000,
+ PMCS_WF6DET = 0x40000000,
+ PMCS_WF5DET = 0x20000000,
+ PMCS_WF4DET = 0x10000000,
+ PMCS_WF3DET = 0x08000000,
+ PMCS_WF2DET = 0x04000000,
+ PMCS_WF1DET = 0x02000000,
+ PMCS_WF0DET = 0x01000000,
+ PMCS_LFDET = 0x00040000,
+ PMCS_LRDET = 0x00020000,
+ PMCS_MFDET = 0x00010000,
+ PMCS_WF7EN = 0x00008000,
+ PMCS_WF6EN = 0x00004000,
+ PMCS_WF5EN = 0x00002000,
+ PMCS_WF4EN = 0x00001000,
+ PMCS_WF3EN = 0x00000800,
+ PMCS_WF2EN = 0x00000400,
+ PMCS_WF1EN = 0x00000200,
+ PMCS_WF0EN = 0x00000100,
+ PMCS_LFEN = 0x00000004,
+ PMCS_LREN = 0x00000002,
+ PMCS_MFEN = 0x00000001,
+};
+
/*
* Giga PHY Status Registers
*/
/*
* SMB Control and Status
*/
-enum jme_smbcsr_bit_mask
-{
+enum jme_smbcsr_bit_mask {
SMBCSR_CNACK = 0x00020000,
SMBCSR_RELOAD = 0x00010000,
SMBCSR_EEPROMD = 0x00000020,
};
#define JME_SMB_TIMEOUT 10 /* 10 msec */
+/*
+ * Timer Control/Status Register
+ */
+enum jme_tmcsr_bit_masks {
+ TMCSR_SWIT = 0x80000000,
+ TMCSR_EN = 0x01000000,
+ TMCSR_CNT = 0x00FFFFFF,
+};
+
/*
* General Purpost REG-0
INTR_TX1 = 0x00000002,
INTR_TX0 = 0x00000001,
};
-static const __u32 INTR_ENABLE = INTR_LINKCH |
+static const __u32 INTR_ENABLE = INTR_SWINTR |
+ INTR_TMINTR |
+ INTR_LINKCH |
INTR_RX0EMP |
INTR_PCCRX0TO |
INTR_PCCRX0 |
*/
__always_inline __u32 jread32(struct jme_adapter *jme, __u32 reg)
{
- return le32_to_cpu(readl(jme->regs + reg));
+ return le32_to_cpu(readl((__u8*)jme->regs + reg));
}
__always_inline void jwrite32(struct jme_adapter *jme, __u32 reg, __u32 val)
{
- writel(cpu_to_le32(val), jme->regs + reg);
+ writel(cpu_to_le32(val), (__u8*)jme->regs + reg);
}
__always_inline void jwrite32f(struct jme_adapter *jme, __u32 reg, __u32 val)
{
/*
* Read after write should cause flush
*/
- writel(cpu_to_le32(val), jme->regs + reg);
- readl(jme->regs + reg);
+ writel(cpu_to_le32(val), (__u8*)jme->regs + reg);
+ readl((__u8*)jme->regs + reg);
}
/*