Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

View file

@ -0,0 +1,57 @@
#
# Toshiba network device configuration
#
config NET_VENDOR_TOSHIBA
bool "Toshiba devices"
default y
depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB || MIPS) || PPC_PS3
---help---
If you have a network (Ethernet) card belonging to this class, say Y
and read the Ethernet-HOWTO, available from
<http://www.tldp.org/docs.html#howto>.
Note that the answer to this question doesn't directly affect the
kernel: saying N will just cause the configurator to skip all
the questions about Toshiba cards. If you say Y, you will be asked
for your specific card in the following questions.
if NET_VENDOR_TOSHIBA
config GELIC_NET
tristate "PS3 Gigabit Ethernet driver"
depends on PPC_PS3
select PS3_SYS_MANAGER
---help---
This driver supports the network device on the PS3 game
console. This driver has built-in support for Ethernet.
To compile this driver as a module, choose M here: the
module will be called ps3_gelic.
config GELIC_WIRELESS
bool "PS3 Wireless support"
depends on GELIC_NET && WLAN
select WIRELESS_EXT
---help---
This option adds the support for the wireless feature of PS3.
If you have the wireless-less model of PS3 or have no plan to
use wireless feature, disabling this option saves memory. As
the driver automatically distinguishes the models, you can
safely enable this option even if you have a wireless-less model.
config SPIDER_NET
tristate "Spider Gigabit Ethernet driver"
depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB)
select FW_LOADER
select SUNGEM_PHY
---help---
This driver supports the Gigabit Ethernet chips present on the
Cell Processor-Based Blades from IBM.
config TC35815
tristate "TOSHIBA TC35815 Ethernet support"
depends on PCI && MIPS
select PHYLIB
endif # NET_VENDOR_TOSHIBA

View file

@ -0,0 +1,10 @@
#
# Makefile for the Toshiba network device drivers.
#
obj-$(CONFIG_GELIC_NET) += ps3_gelic.o
gelic_wireless-$(CONFIG_GELIC_WIRELESS) += ps3_gelic_wireless.o
ps3_gelic-objs += ps3_gelic_net.o $(gelic_wireless-y)
spidernet-y += spider_net.o spider_net_ethtool.o
obj-$(CONFIG_SPIDER_NET) += spidernet.o
obj-$(CONFIG_TC35815) += tc35815.o

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,384 @@
/*
* PS3 Platfom gelic network driver.
*
* Copyright (C) 2007 Sony Computer Entertainment Inc.
* Copyright 2006, 2007 Sony Corporation.
*
* This file is based on: spider_net.h
*
* (C) Copyright IBM Corp. 2005
*
* Authors : Utz Bacher <utz.bacher@de.ibm.com>
* Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _GELIC_NET_H
#define _GELIC_NET_H
/* descriptors */
#define GELIC_NET_RX_DESCRIPTORS 128 /* num of descriptors */
#define GELIC_NET_TX_DESCRIPTORS 128 /* num of descriptors */
#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN
#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN
#define GELIC_NET_RXBUF_ALIGN 128
#define GELIC_CARD_RX_CSUM_DEFAULT 1 /* hw chksum */
#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ
#define GELIC_NET_BROADCAST_ADDR 0xffffffffffffL
#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */
/* virtual interrupt status register bits */
/* INT1 */
#define GELIC_CARD_TX_RAM_FULL_ERR 0x0000000000000001L
#define GELIC_CARD_RX_RAM_FULL_ERR 0x0000000000000002L
#define GELIC_CARD_TX_SHORT_FRAME_ERR 0x0000000000000004L
#define GELIC_CARD_TX_INVALID_DESCR_ERR 0x0000000000000008L
#define GELIC_CARD_RX_FIFO_FULL_ERR 0x0000000000002000L
#define GELIC_CARD_RX_DESCR_CHAIN_END 0x0000000000004000L
#define GELIC_CARD_RX_INVALID_DESCR_ERR 0x0000000000008000L
#define GELIC_CARD_TX_RESPONCE_ERR 0x0000000000010000L
#define GELIC_CARD_RX_RESPONCE_ERR 0x0000000000100000L
#define GELIC_CARD_TX_PROTECTION_ERR 0x0000000000400000L
#define GELIC_CARD_RX_PROTECTION_ERR 0x0000000004000000L
#define GELIC_CARD_TX_TCP_UDP_CHECKSUM_ERR 0x0000000008000000L
#define GELIC_CARD_PORT_STATUS_CHANGED 0x0000000020000000L
#define GELIC_CARD_WLAN_EVENT_RECEIVED 0x0000000040000000L
#define GELIC_CARD_WLAN_COMMAND_COMPLETED 0x0000000080000000L
/* INT 0 */
#define GELIC_CARD_TX_FLAGGED_DESCR 0x0004000000000000L
#define GELIC_CARD_RX_FLAGGED_DESCR 0x0040000000000000L
#define GELIC_CARD_TX_TRANSFER_END 0x0080000000000000L
#define GELIC_CARD_TX_DESCR_CHAIN_END 0x0100000000000000L
#define GELIC_CARD_NUMBER_OF_RX_FRAME 0x1000000000000000L
#define GELIC_CARD_ONE_TIME_COUNT_TIMER 0x4000000000000000L
#define GELIC_CARD_FREE_RUN_COUNT_TIMER 0x8000000000000000L
/* initial interrupt mask */
#define GELIC_CARD_TXINT GELIC_CARD_TX_DESCR_CHAIN_END
#define GELIC_CARD_RXINT (GELIC_CARD_RX_DESCR_CHAIN_END | \
GELIC_CARD_NUMBER_OF_RX_FRAME)
/* RX descriptor data_status bits */
enum gelic_descr_rx_status {
GELIC_DESCR_RXDMADU = 0x80000000, /* destination MAC addr unknown */
GELIC_DESCR_RXLSTFBF = 0x40000000, /* last frame buffer */
GELIC_DESCR_RXIPCHK = 0x20000000, /* IP checksum performed */
GELIC_DESCR_RXTCPCHK = 0x10000000, /* TCP/UDP checksup performed */
GELIC_DESCR_RXWTPKT = 0x00C00000, /*
* wakeup trigger packet
* 01: Magic Packet (TM)
* 10: ARP packet
* 11: Multicast MAC addr
*/
GELIC_DESCR_RXVLNPKT = 0x00200000, /* VLAN packet */
/* bit 20..16 reserved */
GELIC_DESCR_RXRRECNUM = 0x0000ff00, /* reception receipt number */
/* bit 7..0 reserved */
};
#define GELIC_DESCR_DATA_STATUS_CHK_MASK \
(GELIC_DESCR_RXIPCHK | GELIC_DESCR_RXTCPCHK)
/* TX descriptor data_status bits */
enum gelic_descr_tx_status {
GELIC_DESCR_TX_TAIL = 0x00000001, /* gelic treated this
* descriptor was end of
* a tx frame
*/
};
/* RX descriptor data error bits */
enum gelic_descr_rx_error {
/* bit 31 reserved */
GELIC_DESCR_RXALNERR = 0x40000000, /* alignement error 10/100M */
GELIC_DESCR_RXOVERERR = 0x20000000, /* oversize error */
GELIC_DESCR_RXRNTERR = 0x10000000, /* Runt error */
GELIC_DESCR_RXIPCHKERR = 0x08000000, /* IP checksum error */
GELIC_DESCR_RXTCPCHKERR = 0x04000000, /* TCP/UDP checksum error */
GELIC_DESCR_RXDRPPKT = 0x00100000, /* drop packet */
GELIC_DESCR_RXIPFMTERR = 0x00080000, /* IP packet format error */
/* bit 18 reserved */
GELIC_DESCR_RXDATAERR = 0x00020000, /* IP packet format error */
GELIC_DESCR_RXCALERR = 0x00010000, /* cariier extension length
* error */
GELIC_DESCR_RXCREXERR = 0x00008000, /* carrier extension error */
GELIC_DESCR_RXMLTCST = 0x00004000, /* multicast address frame */
/* bit 13..0 reserved */
};
#define GELIC_DESCR_DATA_ERROR_CHK_MASK \
(GELIC_DESCR_RXIPCHKERR | GELIC_DESCR_RXTCPCHKERR)
/* DMA command and status (RX and TX)*/
enum gelic_descr_dma_status {
GELIC_DESCR_DMA_COMPLETE = 0x00000000, /* used in tx */
GELIC_DESCR_DMA_BUFFER_FULL = 0x00000000, /* used in rx */
GELIC_DESCR_DMA_RESPONSE_ERROR = 0x10000000, /* used in rx, tx */
GELIC_DESCR_DMA_PROTECTION_ERROR = 0x20000000, /* used in rx, tx */
GELIC_DESCR_DMA_FRAME_END = 0x40000000, /* used in rx */
GELIC_DESCR_DMA_FORCE_END = 0x50000000, /* used in rx, tx */
GELIC_DESCR_DMA_CARDOWNED = 0xa0000000, /* used in rx, tx */
GELIC_DESCR_DMA_NOT_IN_USE = 0xb0000000, /* any other value */
};
#define GELIC_DESCR_DMA_STAT_MASK (0xf0000000)
/* tx descriptor command and status */
enum gelic_descr_tx_dma_status {
/* [19] */
GELIC_DESCR_TX_DMA_IKE = 0x00080000, /* IPSEC off */
/* [18] */
GELIC_DESCR_TX_DMA_FRAME_TAIL = 0x00040000, /* last descriptor of
* the packet
*/
/* [17..16] */
GELIC_DESCR_TX_DMA_TCP_CHKSUM = 0x00020000, /* TCP packet */
GELIC_DESCR_TX_DMA_UDP_CHKSUM = 0x00030000, /* UDP packet */
GELIC_DESCR_TX_DMA_NO_CHKSUM = 0x00000000, /* no checksum */
/* [1] */
GELIC_DESCR_TX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
* due to chain end
*/
};
#define GELIC_DESCR_DMA_CMD_NO_CHKSUM \
(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_DESCR_TX_DMA_NO_CHKSUM)
#define GELIC_DESCR_DMA_CMD_TCP_CHKSUM \
(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_DESCR_TX_DMA_TCP_CHKSUM)
#define GELIC_DESCR_DMA_CMD_UDP_CHKSUM \
(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_DESCR_TX_DMA_UDP_CHKSUM)
enum gelic_descr_rx_dma_status {
/* [ 1 ] */
GELIC_DESCR_RX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
* due to chain end
*/
};
/* for lv1_net_control */
enum gelic_lv1_net_control_code {
GELIC_LV1_GET_MAC_ADDRESS = 1,
GELIC_LV1_GET_ETH_PORT_STATUS = 2,
GELIC_LV1_SET_NEGOTIATION_MODE = 3,
GELIC_LV1_GET_VLAN_ID = 4,
GELIC_LV1_SET_WOL = 5,
GELIC_LV1_GET_CHANNEL = 6,
GELIC_LV1_POST_WLAN_CMD = 9,
GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
GELIC_LV1_GET_WLAN_EVENT = 11,
};
/* for GELIC_LV1_SET_WOL */
enum gelic_lv1_wol_command {
GELIC_LV1_WOL_MAGIC_PACKET = 1,
GELIC_LV1_WOL_ADD_MATCH_ADDR = 6,
GELIC_LV1_WOL_DELETE_MATCH_ADDR = 7,
};
/* for GELIC_LV1_WOL_MAGIC_PACKET */
enum gelic_lv1_wol_mp_arg {
GELIC_LV1_WOL_MP_DISABLE = 0,
GELIC_LV1_WOL_MP_ENABLE = 1,
};
/* for GELIC_LV1_WOL_{ADD,DELETE}_MATCH_ADDR */
enum gelic_lv1_wol_match_arg {
GELIC_LV1_WOL_MATCH_INDIVIDUAL = 0,
GELIC_LV1_WOL_MATCH_ALL = 1,
};
/* status returened from GET_ETH_PORT_STATUS */
enum gelic_lv1_ether_port_status {
GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,
GELIC_LV1_ETHER_FULL_DUPLEX = 0x0000000000000002L,
GELIC_LV1_ETHER_AUTO_NEG = 0x0000000000000004L,
GELIC_LV1_ETHER_SPEED_10 = 0x0000000000000010L,
GELIC_LV1_ETHER_SPEED_100 = 0x0000000000000020L,
GELIC_LV1_ETHER_SPEED_1000 = 0x0000000000000040L,
GELIC_LV1_ETHER_SPEED_MASK = 0x0000000000000070L,
};
enum gelic_lv1_vlan_index {
/* for outgoing packets */
GELIC_LV1_VLAN_TX_ETHERNET_0 = 0x0000000000000002L,
GELIC_LV1_VLAN_TX_WIRELESS = 0x0000000000000003L,
/* for incoming packets */
GELIC_LV1_VLAN_RX_ETHERNET_0 = 0x0000000000000012L,
GELIC_LV1_VLAN_RX_WIRELESS = 0x0000000000000013L,
};
enum gelic_lv1_phy {
GELIC_LV1_PHY_ETHERNET_0 = 0x0000000000000002L,
};
/* size of hardware part of gelic descriptor */
#define GELIC_DESCR_SIZE (32)
enum gelic_port_type {
GELIC_PORT_ETHERNET_0 = 0,
GELIC_PORT_WIRELESS = 1,
GELIC_PORT_MAX
};
struct gelic_descr {
/* as defined by the hardware */
__be32 buf_addr;
__be32 buf_size;
__be32 next_descr_addr;
__be32 dmac_cmd_status;
__be32 result_size;
__be32 valid_size; /* all zeroes for tx */
__be32 data_status;
__be32 data_error; /* all zeroes for tx */
/* used in the driver */
struct sk_buff *skb;
dma_addr_t bus_addr;
struct gelic_descr *next;
struct gelic_descr *prev;
} __attribute__((aligned(32)));
struct gelic_descr_chain {
/* we walk from tail to head */
struct gelic_descr *head;
struct gelic_descr *tail;
};
struct gelic_vlan_id {
u16 tx;
u16 rx;
};
struct gelic_card {
struct napi_struct napi;
struct net_device *netdev[GELIC_PORT_MAX];
/*
* hypervisor requires irq_status should be
* 8 bytes aligned, but u64 member is
* always disposed in that manner
*/
u64 irq_status;
u64 irq_mask;
struct ps3_system_bus_device *dev;
struct gelic_vlan_id vlan[GELIC_PORT_MAX];
int vlan_required;
struct gelic_descr_chain tx_chain;
struct gelic_descr_chain rx_chain;
/*
* tx_lock guards tx descriptor list and
* tx_dma_progress.
*/
spinlock_t tx_lock;
int tx_dma_progress;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
wait_queue_head_t waitq;
/* only first user should up the card */
struct mutex updown_lock;
atomic_t users;
u64 ether_port_status;
int link_mode;
/* original address returned by kzalloc */
void *unalign;
/*
* each netdevice has copy of irq
*/
unsigned int irq;
struct gelic_descr *tx_top, *rx_top;
struct gelic_descr descr[0]; /* must be the last */
};
struct gelic_port {
struct gelic_card *card;
struct net_device *netdev;
enum gelic_port_type type;
long priv[0]; /* long for alignment */
};
static inline struct gelic_card *port_to_card(struct gelic_port *p)
{
return p->card;
}
static inline struct net_device *port_to_netdev(struct gelic_port *p)
{
return p->netdev;
}
static inline struct gelic_card *netdev_card(struct net_device *d)
{
return ((struct gelic_port *)netdev_priv(d))->card;
}
static inline struct gelic_port *netdev_port(struct net_device *d)
{
return (struct gelic_port *)netdev_priv(d);
}
static inline struct device *ctodev(struct gelic_card *card)
{
return &card->dev->core;
}
static inline u64 bus_id(struct gelic_card *card)
{
return card->dev->bus_id;
}
static inline u64 dev_id(struct gelic_card *card)
{
return card->dev->dev_id;
}
static inline void *port_priv(struct gelic_port *port)
{
return port->priv;
}
#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC
void udbg_shutdown_ps3gelic(void);
#else
static inline void udbg_shutdown_ps3gelic(void) {}
#endif
int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask);
/* shared netdev ops */
void gelic_card_up(struct gelic_card *card);
void gelic_card_down(struct gelic_card *card);
int gelic_net_open(struct net_device *netdev);
int gelic_net_stop(struct net_device *netdev);
int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
void gelic_net_set_multi(struct net_device *netdev);
void gelic_net_tx_timeout(struct net_device *netdev);
int gelic_net_change_mtu(struct net_device *netdev, int new_mtu);
int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card);
/* shared ethtool ops */
void gelic_net_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info);
void gelic_net_poll_controller(struct net_device *netdev);
#endif /* _GELIC_NET_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,326 @@
/*
* PS3 gelic network driver.
*
* Copyright (C) 2007 Sony Computer Entertainment Inc.
* Copyright 2007 Sony Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _GELIC_WIRELESS_H
#define _GELIC_WIRELESS_H
#include <linux/wireless.h>
#include <net/iw_handler.h>
/* return value from GELIC_LV1_GET_WLAN_EVENT netcontrol */
enum gelic_lv1_wl_event {
GELIC_LV1_WL_EVENT_DEVICE_READY = 0x01, /* Eurus ready */
GELIC_LV1_WL_EVENT_SCAN_COMPLETED = 0x02, /* Scan has completed */
GELIC_LV1_WL_EVENT_DEAUTH = 0x04, /* Deauthed by the AP */
GELIC_LV1_WL_EVENT_BEACON_LOST = 0x08, /* Beacon lost detected */
GELIC_LV1_WL_EVENT_CONNECTED = 0x10, /* Connected to AP */
GELIC_LV1_WL_EVENT_WPA_CONNECTED = 0x20, /* WPA connection */
GELIC_LV1_WL_EVENT_WPA_ERROR = 0x40, /* MIC error */
};
/* arguments for GELIC_LV1_POST_WLAN_COMMAND netcontrol */
enum gelic_eurus_command {
GELIC_EURUS_CMD_ASSOC = 1, /* association start */
GELIC_EURUS_CMD_DISASSOC = 2, /* disassociate */
GELIC_EURUS_CMD_START_SCAN = 3, /* scan start */
GELIC_EURUS_CMD_GET_SCAN = 4, /* get scan result */
GELIC_EURUS_CMD_SET_COMMON_CFG = 5, /* set common config */
GELIC_EURUS_CMD_GET_COMMON_CFG = 6, /* set common config */
GELIC_EURUS_CMD_SET_WEP_CFG = 7, /* set WEP config */
GELIC_EURUS_CMD_GET_WEP_CFG = 8, /* get WEP config */
GELIC_EURUS_CMD_SET_WPA_CFG = 9, /* set WPA config */
GELIC_EURUS_CMD_GET_WPA_CFG = 10, /* get WPA config */
GELIC_EURUS_CMD_GET_RSSI_CFG = 11, /* get RSSI info. */
GELIC_EURUS_CMD_MAX_INDEX
};
/* for GELIC_EURUS_CMD_COMMON_CFG */
enum gelic_eurus_bss_type {
GELIC_EURUS_BSS_INFRA = 0,
GELIC_EURUS_BSS_ADHOC = 1, /* not supported */
};
enum gelic_eurus_auth_method {
GELIC_EURUS_AUTH_OPEN = 0, /* FIXME: WLAN_AUTH_OPEN */
GELIC_EURUS_AUTH_SHARED = 1, /* not supported */
};
enum gelic_eurus_opmode {
GELIC_EURUS_OPMODE_11BG = 0, /* 802.11b/g */
GELIC_EURUS_OPMODE_11B = 1, /* 802.11b only */
GELIC_EURUS_OPMODE_11G = 2, /* 802.11g only */
};
struct gelic_eurus_common_cfg {
/* all fields are big endian */
u16 scan_index;
u16 bss_type; /* infra or adhoc */
u16 auth_method; /* shared key or open */
u16 op_mode; /* B/G */
} __packed;
/* for GELIC_EURUS_CMD_WEP_CFG */
enum gelic_eurus_wep_security {
GELIC_EURUS_WEP_SEC_NONE = 0,
GELIC_EURUS_WEP_SEC_40BIT = 1,
GELIC_EURUS_WEP_SEC_104BIT = 2,
};
struct gelic_eurus_wep_cfg {
/* all fields are big endian */
u16 security;
u8 key[4][16];
} __packed;
/* for GELIC_EURUS_CMD_WPA_CFG */
enum gelic_eurus_wpa_security {
GELIC_EURUS_WPA_SEC_NONE = 0x0000,
/* group=TKIP, pairwise=TKIP */
GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP = 0x0001,
/* group=AES, pairwise=AES */
GELIC_EURUS_WPA_SEC_WPA_AES_AES = 0x0002,
/* group=TKIP, pairwise=TKIP */
GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP = 0x0004,
/* group=AES, pairwise=AES */
GELIC_EURUS_WPA_SEC_WPA2_AES_AES = 0x0008,
/* group=TKIP, pairwise=AES */
GELIC_EURUS_WPA_SEC_WPA_TKIP_AES = 0x0010,
/* group=TKIP, pairwise=AES */
GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES = 0x0020,
};
enum gelic_eurus_wpa_psk_type {
GELIC_EURUS_WPA_PSK_PASSPHRASE = 0, /* passphrase string */
GELIC_EURUS_WPA_PSK_BIN = 1, /* 32 bytes binary key */
};
#define GELIC_WL_EURUS_PSK_MAX_LEN 64
#define WPA_PSK_LEN 32 /* WPA spec says 256bit */
struct gelic_eurus_wpa_cfg {
/* all fields are big endian */
u16 security;
u16 psk_type; /* psk key encoding type */
u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN]; /* psk key; hex or passphrase */
} __packed;
/* for GELIC_EURUS_CMD_{START,GET}_SCAN */
enum gelic_eurus_scan_capability {
GELIC_EURUS_SCAN_CAP_ADHOC = 0x0000,
GELIC_EURUS_SCAN_CAP_INFRA = 0x0001,
GELIC_EURUS_SCAN_CAP_MASK = 0x0001,
};
enum gelic_eurus_scan_sec_type {
GELIC_EURUS_SCAN_SEC_NONE = 0x0000,
GELIC_EURUS_SCAN_SEC_WEP = 0x0100,
GELIC_EURUS_SCAN_SEC_WPA = 0x0200,
GELIC_EURUS_SCAN_SEC_WPA2 = 0x0400,
GELIC_EURUS_SCAN_SEC_MASK = 0x0f00,
};
enum gelic_eurus_scan_sec_wep_type {
GELIC_EURUS_SCAN_SEC_WEP_UNKNOWN = 0x0000,
GELIC_EURUS_SCAN_SEC_WEP_40 = 0x0001,
GELIC_EURUS_SCAN_SEC_WEP_104 = 0x0002,
GELIC_EURUS_SCAN_SEC_WEP_MASK = 0x0003,
};
enum gelic_eurus_scan_sec_wpa_type {
GELIC_EURUS_SCAN_SEC_WPA_UNKNOWN = 0x0000,
GELIC_EURUS_SCAN_SEC_WPA_TKIP = 0x0001,
GELIC_EURUS_SCAN_SEC_WPA_AES = 0x0002,
GELIC_EURUS_SCAN_SEC_WPA_MASK = 0x0003,
};
/*
* hw BSS information structure returned from GELIC_EURUS_CMD_GET_SCAN
*/
struct gelic_eurus_scan_info {
/* all fields are big endian */
__be16 size;
__be16 rssi; /* percentage */
__be16 channel; /* channel number */
__be16 beacon_period; /* FIXME: in msec unit */
__be16 capability;
__be16 security;
u8 bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
u8 essid[32]; /* IW_ESSID_MAX_SIZE */
u8 rate[16]; /* first 12 are valid */
u8 ext_rate[16]; /* first 16 are valid */
__be32 reserved1;
__be32 reserved2;
__be32 reserved3;
__be32 reserved4;
u8 elements[0]; /* ie */
} __packed;
/* the hypervisor returns bbs up to 16 */
#define GELIC_EURUS_MAX_SCAN (16)
struct gelic_wl_scan_info {
struct list_head list;
struct gelic_eurus_scan_info *hwinfo;
int valid; /* set 1 if this entry was in latest scanned list
* from Eurus */
unsigned int eurus_index; /* index in the Eurus list */
unsigned long last_scanned; /* acquired time */
unsigned int rate_len;
unsigned int rate_ext_len;
unsigned int essid_len;
};
/* for GELIC_EURUS_CMD_GET_RSSI */
struct gelic_eurus_rssi_info {
/* big endian */
__be16 rssi;
} __packed;
/* for 'stat' member of gelic_wl_info */
enum gelic_wl_info_status_bit {
GELIC_WL_STAT_CONFIGURED,
GELIC_WL_STAT_CH_INFO, /* ch info acquired */
GELIC_WL_STAT_ESSID_SET, /* ESSID specified by userspace */
GELIC_WL_STAT_BSSID_SET, /* BSSID specified by userspace */
GELIC_WL_STAT_WPA_PSK_SET, /* PMK specified by userspace */
GELIC_WL_STAT_WPA_LEVEL_SET, /* WEP or WPA[2] selected */
};
/* for 'scan_stat' member of gelic_wl_info */
enum gelic_wl_scan_state {
/* just initialized or get last scan result failed */
GELIC_WL_SCAN_STAT_INIT,
/* scan request issued, accepted or chip is scanning */
GELIC_WL_SCAN_STAT_SCANNING,
/* scan results retrieved */
GELIC_WL_SCAN_STAT_GOT_LIST,
};
/* for 'cipher_method' */
enum gelic_wl_cipher_method {
GELIC_WL_CIPHER_NONE,
GELIC_WL_CIPHER_WEP,
GELIC_WL_CIPHER_TKIP,
GELIC_WL_CIPHER_AES,
};
/* for 'wpa_level' */
enum gelic_wl_wpa_level {
GELIC_WL_WPA_LEVEL_NONE,
GELIC_WL_WPA_LEVEL_WPA,
GELIC_WL_WPA_LEVEL_WPA2,
};
/* for 'assoc_stat' */
enum gelic_wl_assoc_state {
GELIC_WL_ASSOC_STAT_DISCONN,
GELIC_WL_ASSOC_STAT_ASSOCIATING,
GELIC_WL_ASSOC_STAT_ASSOCIATED,
};
/* part of private data alloc_etherdev() allocated */
#define GELIC_WEP_KEYS 4
struct gelic_wl_info {
/* bss list */
struct mutex scan_lock;
struct list_head network_list;
struct list_head network_free_list;
struct gelic_wl_scan_info *networks;
unsigned long scan_age; /* last scanned time */
enum gelic_wl_scan_state scan_stat;
struct completion scan_done;
/* eurus command queue */
struct workqueue_struct *eurus_cmd_queue;
struct completion cmd_done_intr;
/* eurus event handling */
struct workqueue_struct *event_queue;
struct delayed_work event_work;
/* wl status bits */
unsigned long stat;
enum gelic_eurus_auth_method auth_method; /* open/shared */
enum gelic_wl_cipher_method group_cipher_method;
enum gelic_wl_cipher_method pairwise_cipher_method;
enum gelic_wl_wpa_level wpa_level; /* wpa/wpa2 */
/* association handling */
struct mutex assoc_stat_lock;
struct delayed_work assoc_work;
enum gelic_wl_assoc_state assoc_stat;
struct completion assoc_done;
spinlock_t lock;
u16 ch_info; /* available channels. bit0 = ch1 */
/* WEP keys */
u8 key[GELIC_WEP_KEYS][IW_ENCODING_TOKEN_MAX];
unsigned long key_enabled;
unsigned int key_len[GELIC_WEP_KEYS];
unsigned int current_key;
/* WWPA PSK */
u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN];
enum gelic_eurus_wpa_psk_type psk_type;
unsigned int psk_len;
u8 essid[IW_ESSID_MAX_SIZE];
u8 bssid[ETH_ALEN]; /* userland requested */
u8 active_bssid[ETH_ALEN]; /* associated bssid */
unsigned int essid_len;
struct iw_public_data wireless_data;
struct iw_statistics iwstat;
};
#define GELIC_WL_BSS_MAX_ENT 32
#define GELIC_WL_ASSOC_RETRY 50
static inline struct gelic_port *wl_port(struct gelic_wl_info *wl)
{
return container_of((void *)wl, struct gelic_port, priv);
}
static inline struct gelic_wl_info *port_wl(struct gelic_port *port)
{
return port_priv(port);
}
struct gelic_eurus_cmd {
struct work_struct work;
struct gelic_wl_info *wl;
unsigned int cmd; /* command code */
u64 tag;
u64 size;
void *buffer;
unsigned int buf_size;
struct completion done;
int status;
u64 cmd_status;
};
/* private ioctls to pass PSK */
#define GELIC_WL_PRIV_SET_PSK (SIOCIWFIRSTPRIV + 0)
#define GELIC_WL_PRIV_GET_PSK (SIOCIWFIRSTPRIV + 1)
int gelic_wl_driver_probe(struct gelic_card *card);
int gelic_wl_driver_remove(struct gelic_card *card);
void gelic_wl_interrupt(struct net_device *netdev, u64 status);
#endif /* _GELIC_WIRELESS_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,489 @@
/*
* Network device driver for Cell Processor-Based Blade and Celleb platform
*
* (C) Copyright IBM Corp. 2005
* (C) Copyright 2006 TOSHIBA CORPORATION
*
* Authors : Utz Bacher <utz.bacher@de.ibm.com>
* Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _SPIDER_NET_H
#define _SPIDER_NET_H
#define VERSION "2.0 B"
#include <linux/sungem_phy.h>
int spider_net_stop(struct net_device *netdev);
int spider_net_open(struct net_device *netdev);
extern const struct ethtool_ops spider_net_ethtool_ops;
extern char spider_net_driver_name[];
#define SPIDER_NET_MAX_FRAME 2312
#define SPIDER_NET_MAX_MTU 2294
#define SPIDER_NET_MIN_MTU 64
#define SPIDER_NET_RXBUF_ALIGN 128
#define SPIDER_NET_RX_DESCRIPTORS_DEFAULT 256
#define SPIDER_NET_RX_DESCRIPTORS_MIN 16
#define SPIDER_NET_RX_DESCRIPTORS_MAX 512
#define SPIDER_NET_TX_DESCRIPTORS_DEFAULT 256
#define SPIDER_NET_TX_DESCRIPTORS_MIN 16
#define SPIDER_NET_TX_DESCRIPTORS_MAX 512
#define SPIDER_NET_TX_TIMER (HZ/5)
#define SPIDER_NET_ANEG_TIMER (HZ)
#define SPIDER_NET_ANEG_TIMEOUT 5
#define SPIDER_NET_RX_CSUM_DEFAULT 1
#define SPIDER_NET_WATCHDOG_TIMEOUT 50*HZ
#define SPIDER_NET_NAPI_WEIGHT 64
#define SPIDER_NET_FIRMWARE_SEQS 6
#define SPIDER_NET_FIRMWARE_SEQWORDS 1024
#define SPIDER_NET_FIRMWARE_LEN (SPIDER_NET_FIRMWARE_SEQS * \
SPIDER_NET_FIRMWARE_SEQWORDS * \
sizeof(u32))
#define SPIDER_NET_FIRMWARE_NAME "spider_fw.bin"
/** spider_net SMMIO registers */
#define SPIDER_NET_GHIINT0STS 0x00000000
#define SPIDER_NET_GHIINT1STS 0x00000004
#define SPIDER_NET_GHIINT2STS 0x00000008
#define SPIDER_NET_GHIINT0MSK 0x00000010
#define SPIDER_NET_GHIINT1MSK 0x00000014
#define SPIDER_NET_GHIINT2MSK 0x00000018
#define SPIDER_NET_GRESUMINTNUM 0x00000020
#define SPIDER_NET_GREINTNUM 0x00000024
#define SPIDER_NET_GFFRMNUM 0x00000028
#define SPIDER_NET_GFAFRMNUM 0x0000002c
#define SPIDER_NET_GFBFRMNUM 0x00000030
#define SPIDER_NET_GFCFRMNUM 0x00000034
#define SPIDER_NET_GFDFRMNUM 0x00000038
/* clear them (don't use it) */
#define SPIDER_NET_GFREECNNUM 0x0000003c
#define SPIDER_NET_GONETIMENUM 0x00000040
#define SPIDER_NET_GTOUTFRMNUM 0x00000044
#define SPIDER_NET_GTXMDSET 0x00000050
#define SPIDER_NET_GPCCTRL 0x00000054
#define SPIDER_NET_GRXMDSET 0x00000058
#define SPIDER_NET_GIPSECINIT 0x0000005c
#define SPIDER_NET_GFTRESTRT 0x00000060
#define SPIDER_NET_GRXDMAEN 0x00000064
#define SPIDER_NET_GMRWOLCTRL 0x00000068
#define SPIDER_NET_GPCWOPCMD 0x0000006c
#define SPIDER_NET_GPCROPCMD 0x00000070
#define SPIDER_NET_GTTFRMCNT 0x00000078
#define SPIDER_NET_GTESTMD 0x0000007c
#define SPIDER_NET_GSINIT 0x00000080
#define SPIDER_NET_GSnPRGADR 0x00000084
#define SPIDER_NET_GSnPRGDAT 0x00000088
#define SPIDER_NET_GMACOPEMD 0x00000100
#define SPIDER_NET_GMACLENLMT 0x00000108
#define SPIDER_NET_GMACST 0x00000110
#define SPIDER_NET_GMACINTEN 0x00000118
#define SPIDER_NET_GMACPHYCTRL 0x00000120
#define SPIDER_NET_GMACAPAUSE 0x00000154
#define SPIDER_NET_GMACTXPAUSE 0x00000164
#define SPIDER_NET_GMACMODE 0x000001b0
#define SPIDER_NET_GMACBSTLMT 0x000001b4
#define SPIDER_NET_GMACUNIMACU 0x000001c0
#define SPIDER_NET_GMACUNIMACL 0x000001c8
#define SPIDER_NET_GMRMHFILnR 0x00000400
#define SPIDER_NET_MULTICAST_HASHES 256
#define SPIDER_NET_GMRUAFILnR 0x00000500
#define SPIDER_NET_GMRUA0FIL15R 0x00000578
#define SPIDER_NET_GTTQMSK 0x00000934
/* RX DMA controller registers, all 0x00000a.. are for DMA controller A,
* 0x00000b.. for DMA controller B, etc. */
#define SPIDER_NET_GDADCHA 0x00000a00
#define SPIDER_NET_GDADMACCNTR 0x00000a04
#define SPIDER_NET_GDACTDPA 0x00000a08
#define SPIDER_NET_GDACTDCNT 0x00000a0c
#define SPIDER_NET_GDACDBADDR 0x00000a20
#define SPIDER_NET_GDACDBSIZE 0x00000a24
#define SPIDER_NET_GDACNEXTDA 0x00000a28
#define SPIDER_NET_GDACCOMST 0x00000a2c
#define SPIDER_NET_GDAWBCOMST 0x00000a30
#define SPIDER_NET_GDAWBRSIZE 0x00000a34
#define SPIDER_NET_GDAWBVSIZE 0x00000a38
#define SPIDER_NET_GDAWBTRST 0x00000a3c
#define SPIDER_NET_GDAWBTRERR 0x00000a40
/* TX DMA controller registers */
#define SPIDER_NET_GDTDCHA 0x00000e00
#define SPIDER_NET_GDTDMACCNTR 0x00000e04
#define SPIDER_NET_GDTCDPA 0x00000e08
#define SPIDER_NET_GDTDMASEL 0x00000e14
#define SPIDER_NET_ECMODE 0x00000f00
/* clock and reset control register */
#define SPIDER_NET_CKRCTRL 0x00000ff0
/** SCONFIG registers */
#define SPIDER_NET_SCONFIG_IOACTE 0x00002810
/** interrupt mask registers */
#define SPIDER_NET_INT0_MASK_VALUE 0x3f7fe2c7
#define SPIDER_NET_INT1_MASK_VALUE 0x0000fff2
#define SPIDER_NET_INT2_MASK_VALUE 0x000003f1
/* we rely on flagged descriptor interrupts */
#define SPIDER_NET_FRAMENUM_VALUE 0x00000000
/* set this first, then the FRAMENUM_VALUE */
#define SPIDER_NET_GFXFRAMES_VALUE 0x00000000
#define SPIDER_NET_STOP_SEQ_VALUE 0x00000000
#define SPIDER_NET_RUN_SEQ_VALUE 0x0000007e
#define SPIDER_NET_PHY_CTRL_VALUE 0x00040040
/* #define SPIDER_NET_PHY_CTRL_VALUE 0x01070080*/
#define SPIDER_NET_RXMODE_VALUE 0x00000011
/* auto retransmission in case of MAC aborts */
#define SPIDER_NET_TXMODE_VALUE 0x00010000
#define SPIDER_NET_RESTART_VALUE 0x00000000
#define SPIDER_NET_WOL_VALUE 0x00001111
#if 0
#define SPIDER_NET_WOL_VALUE 0x00000000
#endif
#define SPIDER_NET_IPSECINIT_VALUE 0x6f716f71
/* pause frames: automatic, no upper retransmission count */
/* outside loopback mode: ETOMOD signal dont matter, not connected */
/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
#define SPIDER_NET_OPMODE_VALUE 0x00000067
/*#define SPIDER_NET_OPMODE_VALUE 0x001b0062*/
#define SPIDER_NET_LENLMT_VALUE 0x00000908
#define SPIDER_NET_MACAPAUSE_VALUE 0x00000800 /* about 1 ms */
#define SPIDER_NET_TXPAUSE_VALUE 0x00000000
#define SPIDER_NET_MACMODE_VALUE 0x00000001
#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */
/* DMAC control register GDMACCNTR
*
* 1(0) enable r/tx dma
* 0000000 fixed to 0
*
* 000000 fixed to 0
* 0(1) en/disable descr writeback on force end
* 0(1) force end
*
* 000000 fixed to 0
* 00 burst alignment: 128 bytes
* 11 burst alignment: 1024 bytes
*
* 00000 fixed to 0
* 0 descr writeback size 32 bytes
* 0(1) descr chain end interrupt enable
* 0(1) descr status writeback enable */
/* to set RX_DMA_EN */
#define SPIDER_NET_DMA_RX_VALUE 0x80000000
#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003
/* to set TX_DMA_EN */
#define SPIDER_NET_TX_DMA_EN 0x80000000
#define SPIDER_NET_GDTBSTA 0x00000300
#define SPIDER_NET_GDTDCEIDIS 0x00000002
#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \
SPIDER_NET_GDTDCEIDIS | \
SPIDER_NET_GDTBSTA
#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003
/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */
#define SPIDER_NET_UA_DESCR_VALUE 0x00080000
#define SPIDER_NET_PROMISC_VALUE 0x00080000
#define SPIDER_NET_NONPROMISC_VALUE 0x00000000
#define SPIDER_NET_DMASEL_VALUE 0x00000001
#define SPIDER_NET_ECMODE_VALUE 0x00000000
#define SPIDER_NET_CKRCTRL_RUN_VALUE 0x1fff010f
#define SPIDER_NET_CKRCTRL_STOP_VALUE 0x0000010f
#define SPIDER_NET_SBIMSTATE_VALUE 0x00000000
#define SPIDER_NET_SBTMSTATE_VALUE 0x00000000
/* SPIDER_NET_GHIINT0STS bits, in reverse order so that they can be used
* with 1 << SPIDER_NET_... */
enum spider_net_int0_status {
SPIDER_NET_GPHYINT = 0,
SPIDER_NET_GMAC2INT,
SPIDER_NET_GMAC1INT,
SPIDER_NET_GIPSINT,
SPIDER_NET_GFIFOINT,
SPIDER_NET_GDMACINT,
SPIDER_NET_GSYSINT,
SPIDER_NET_GPWOPCMPINT,
SPIDER_NET_GPROPCMPINT,
SPIDER_NET_GPWFFINT,
SPIDER_NET_GRMDADRINT,
SPIDER_NET_GRMARPINT,
SPIDER_NET_GRMMPINT,
SPIDER_NET_GDTDEN0INT,
SPIDER_NET_GDDDEN0INT,
SPIDER_NET_GDCDEN0INT,
SPIDER_NET_GDBDEN0INT,
SPIDER_NET_GDADEN0INT,
SPIDER_NET_GDTFDCINT,
SPIDER_NET_GDDFDCINT,
SPIDER_NET_GDCFDCINT,
SPIDER_NET_GDBFDCINT,
SPIDER_NET_GDAFDCINT,
SPIDER_NET_GTTEDINT,
SPIDER_NET_GDTDCEINT,
SPIDER_NET_GRFDNMINT,
SPIDER_NET_GRFCNMINT,
SPIDER_NET_GRFBNMINT,
SPIDER_NET_GRFANMINT,
SPIDER_NET_GRFNMINT,
SPIDER_NET_G1TMCNTINT,
SPIDER_NET_GFREECNTINT
};
/* GHIINT1STS bits */
enum spider_net_int1_status {
SPIDER_NET_GTMFLLINT = 0,
SPIDER_NET_GRMFLLINT,
SPIDER_NET_GTMSHTINT,
SPIDER_NET_GDTINVDINT,
SPIDER_NET_GRFDFLLINT,
SPIDER_NET_GDDDCEINT,
SPIDER_NET_GDDINVDINT,
SPIDER_NET_GRFCFLLINT,
SPIDER_NET_GDCDCEINT,
SPIDER_NET_GDCINVDINT,
SPIDER_NET_GRFBFLLINT,
SPIDER_NET_GDBDCEINT,
SPIDER_NET_GDBINVDINT,
SPIDER_NET_GRFAFLLINT,
SPIDER_NET_GDADCEINT,
SPIDER_NET_GDAINVDINT,
SPIDER_NET_GDTRSERINT,
SPIDER_NET_GDDRSERINT,
SPIDER_NET_GDCRSERINT,
SPIDER_NET_GDBRSERINT,
SPIDER_NET_GDARSERINT,
SPIDER_NET_GDSERINT,
SPIDER_NET_GDTPTERINT,
SPIDER_NET_GDDPTERINT,
SPIDER_NET_GDCPTERINT,
SPIDER_NET_GDBPTERINT,
SPIDER_NET_GDAPTERINT
};
/* GHIINT2STS bits */
enum spider_net_int2_status {
SPIDER_NET_GPROPERINT = 0,
SPIDER_NET_GMCTCRSNGINT,
SPIDER_NET_GMCTLCOLINT,
SPIDER_NET_GMCTTMOTINT,
SPIDER_NET_GMCRCAERINT,
SPIDER_NET_GMCRCALERINT,
SPIDER_NET_GMCRALNERINT,
SPIDER_NET_GMCROVRINT,
SPIDER_NET_GMCRRNTINT,
SPIDER_NET_GMCRRXERINT,
SPIDER_NET_GTITCSERINT,
SPIDER_NET_GTIFMTERINT,
SPIDER_NET_GTIPKTRVKINT,
SPIDER_NET_GTISPINGINT,
SPIDER_NET_GTISADNGINT,
SPIDER_NET_GTISPDNGINT,
SPIDER_NET_GRIFMTERINT,
SPIDER_NET_GRIPKTRVKINT,
SPIDER_NET_GRISPINGINT,
SPIDER_NET_GRISADNGINT,
SPIDER_NET_GRISPDNGINT
};
#define SPIDER_NET_TXINT (1 << SPIDER_NET_GDTFDCINT)
/* We rely on flagged descriptor interrupts */
#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) )
#define SPIDER_NET_LINKINT ( 1 << SPIDER_NET_GMAC2INT )
#define SPIDER_NET_ERRINT ( 0xffffffff & \
(~SPIDER_NET_TXINT) & \
(~SPIDER_NET_RXINT) & \
(~SPIDER_NET_LINKINT) )
#define SPIDER_NET_GPREXEC 0x80000000
#define SPIDER_NET_GPRDAT_MASK 0x0000ffff
#define SPIDER_NET_DMAC_NOINTR_COMPLETE 0x00800000
#define SPIDER_NET_DMAC_TXFRMTL 0x00040000
#define SPIDER_NET_DMAC_TCP 0x00020000
#define SPIDER_NET_DMAC_UDP 0x00030000
#define SPIDER_NET_TXDCEST 0x08000000
#define SPIDER_NET_DESCR_RXFDIS 0x00000001
#define SPIDER_NET_DESCR_RXDCEIS 0x00000002
#define SPIDER_NET_DESCR_RXDEN0IS 0x00000004
#define SPIDER_NET_DESCR_RXINVDIS 0x00000008
#define SPIDER_NET_DESCR_RXRERRIS 0x00000010
#define SPIDER_NET_DESCR_RXFDCIMS 0x00000100
#define SPIDER_NET_DESCR_RXDCEIMS 0x00000200
#define SPIDER_NET_DESCR_RXDEN0IMS 0x00000400
#define SPIDER_NET_DESCR_RXINVDIMS 0x00000800
#define SPIDER_NET_DESCR_RXRERRMIS 0x00001000
#define SPIDER_NET_DESCR_UNUSED 0x077fe0e0
#define SPIDER_NET_DESCR_IND_PROC_MASK 0xF0000000
#define SPIDER_NET_DESCR_COMPLETE 0x00000000 /* used in rx and tx */
#define SPIDER_NET_DESCR_RESPONSE_ERROR 0x10000000 /* used in rx and tx */
#define SPIDER_NET_DESCR_PROTECTION_ERROR 0x20000000 /* used in rx and tx */
#define SPIDER_NET_DESCR_FRAME_END 0x40000000 /* used in rx */
#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */
#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */
#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000
#define SPIDER_NET_DESCR_TXDESFLG 0x00800000
#define SPIDER_NET_DESCR_BAD_STATUS (SPIDER_NET_DESCR_RXDEN0IS | \
SPIDER_NET_DESCR_RXRERRIS | \
SPIDER_NET_DESCR_RXDEN0IMS | \
SPIDER_NET_DESCR_RXINVDIMS | \
SPIDER_NET_DESCR_RXRERRMIS | \
SPIDER_NET_DESCR_UNUSED)
/* Descriptor, as defined by the hardware */
struct spider_net_hw_descr {
u32 buf_addr;
u32 buf_size;
u32 next_descr_addr;
u32 dmac_cmd_status;
u32 result_size;
u32 valid_size; /* all zeroes for tx */
u32 data_status;
u32 data_error; /* all zeroes for tx */
} __attribute__((aligned(32)));
struct spider_net_descr {
struct spider_net_hw_descr *hwdescr;
struct sk_buff *skb;
u32 bus_addr;
struct spider_net_descr *next;
struct spider_net_descr *prev;
};
struct spider_net_descr_chain {
spinlock_t lock;
struct spider_net_descr *head;
struct spider_net_descr *tail;
struct spider_net_descr *ring;
int num_desc;
struct spider_net_hw_descr *hwring;
dma_addr_t dma_addr;
};
/* descriptor data_status bits */
#define SPIDER_NET_RX_IPCHK 29
#define SPIDER_NET_RX_TCPCHK 28
#define SPIDER_NET_VLAN_PACKET 21
#define SPIDER_NET_DATA_STATUS_CKSUM_MASK ( (1 << SPIDER_NET_RX_IPCHK) | \
(1 << SPIDER_NET_RX_TCPCHK) )
/* descriptor data_error bits */
#define SPIDER_NET_RX_IPCHKERR 27
#define SPIDER_NET_RX_RXTCPCHKERR 28
#define SPIDER_NET_DATA_ERR_CKSUM_MASK (1 << SPIDER_NET_RX_IPCHKERR)
/* the cases we don't pass the packet to the stack.
* 701b8000 would be correct, but every packets gets that flag */
#define SPIDER_NET_DESTROY_RX_FLAGS 0x700b8000
#define SPIDER_NET_DEFAULT_MSG ( NETIF_MSG_DRV | \
NETIF_MSG_PROBE | \
NETIF_MSG_LINK | \
NETIF_MSG_TIMER | \
NETIF_MSG_IFDOWN | \
NETIF_MSG_IFUP | \
NETIF_MSG_RX_ERR | \
NETIF_MSG_TX_ERR | \
NETIF_MSG_TX_QUEUED | \
NETIF_MSG_INTR | \
NETIF_MSG_TX_DONE | \
NETIF_MSG_RX_STATUS | \
NETIF_MSG_PKTDATA | \
NETIF_MSG_HW | \
NETIF_MSG_WOL )
struct spider_net_extra_stats {
unsigned long rx_desc_error;
unsigned long tx_timeouts;
unsigned long alloc_rx_skb_error;
unsigned long rx_iommu_map_error;
unsigned long tx_iommu_map_error;
unsigned long rx_desc_unk_state;
};
struct spider_net_card {
struct net_device *netdev;
struct pci_dev *pdev;
struct mii_phy phy;
struct napi_struct napi;
int medium;
void __iomem *regs;
struct spider_net_descr_chain tx_chain;
struct spider_net_descr_chain rx_chain;
struct spider_net_descr *low_watermark;
int aneg_count;
struct timer_list aneg_timer;
struct timer_list tx_timer;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
wait_queue_head_t waitq;
int num_rx_ints;
int ignore_rx_ramfull;
/* for ethtool */
int msg_enable;
struct spider_net_extra_stats spider_stats;
/* Must be last item in struct */
struct spider_net_descr darray[0];
};
#endif

View file

@ -0,0 +1,181 @@
/*
* Network device driver for Cell Processor-Based Blade
*
* (C) Copyright IBM Corp. 2005
*
* Authors : Utz Bacher <utz.bacher@de.ibm.com>
* Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/pci.h>
#include "spider_net.h"
static struct {
const char str[ETH_GSTRING_LEN];
} ethtool_stats_keys[] = {
{ "tx_packets" },
{ "tx_bytes" },
{ "rx_packets" },
{ "rx_bytes" },
{ "tx_errors" },
{ "tx_dropped" },
{ "rx_dropped" },
{ "rx_descriptor_error" },
{ "tx_timeouts" },
{ "alloc_rx_skb_error" },
{ "rx_iommu_map_error" },
{ "tx_iommu_map_error" },
{ "rx_desc_unk_state" },
};
static int
spider_net_ethtool_get_settings(struct net_device *netdev,
struct ethtool_cmd *cmd)
{
struct spider_net_card *card;
card = netdev_priv(netdev);
cmd->supported = (SUPPORTED_1000baseT_Full |
SUPPORTED_FIBRE);
cmd->advertising = (ADVERTISED_1000baseT_Full |
ADVERTISED_FIBRE);
cmd->port = PORT_FIBRE;
ethtool_cmd_speed_set(cmd, card->phy.speed);
cmd->duplex = DUPLEX_FULL;
return 0;
}
static void
spider_net_ethtool_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{
struct spider_net_card *card;
card = netdev_priv(netdev);
/* clear and fill out info */
strlcpy(drvinfo->driver, spider_net_driver_name,
sizeof(drvinfo->driver));
strlcpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
strlcpy(drvinfo->fw_version, "no information",
sizeof(drvinfo->fw_version));
strlcpy(drvinfo->bus_info, pci_name(card->pdev),
sizeof(drvinfo->bus_info));
}
static void
spider_net_ethtool_get_wol(struct net_device *netdev,
struct ethtool_wolinfo *wolinfo)
{
/* no support for wol */
wolinfo->supported = 0;
wolinfo->wolopts = 0;
}
static u32
spider_net_ethtool_get_msglevel(struct net_device *netdev)
{
struct spider_net_card *card;
card = netdev_priv(netdev);
return card->msg_enable;
}
static void
spider_net_ethtool_set_msglevel(struct net_device *netdev,
u32 level)
{
struct spider_net_card *card;
card = netdev_priv(netdev);
card->msg_enable = level;
}
static int
spider_net_ethtool_nway_reset(struct net_device *netdev)
{
if (netif_running(netdev)) {
spider_net_stop(netdev);
spider_net_open(netdev);
}
return 0;
}
static void
spider_net_ethtool_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ering)
{
struct spider_net_card *card = netdev_priv(netdev);
ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
ering->tx_pending = card->tx_chain.num_desc;
ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
ering->rx_pending = card->rx_chain.num_desc;
}
static int spider_net_get_sset_count(struct net_device *netdev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
return ARRAY_SIZE(ethtool_stats_keys);
default:
return -EOPNOTSUPP;
}
}
static void spider_net_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
struct spider_net_card *card = netdev_priv(netdev);
data[0] = netdev->stats.tx_packets;
data[1] = netdev->stats.tx_bytes;
data[2] = netdev->stats.rx_packets;
data[3] = netdev->stats.rx_bytes;
data[4] = netdev->stats.tx_errors;
data[5] = netdev->stats.tx_dropped;
data[6] = netdev->stats.rx_dropped;
data[7] = card->spider_stats.rx_desc_error;
data[8] = card->spider_stats.tx_timeouts;
data[9] = card->spider_stats.alloc_rx_skb_error;
data[10] = card->spider_stats.rx_iommu_map_error;
data[11] = card->spider_stats.tx_iommu_map_error;
data[12] = card->spider_stats.rx_desc_unk_state;
}
static void spider_net_get_strings(struct net_device *netdev, u32 stringset,
u8 *data)
{
memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
}
const struct ethtool_ops spider_net_ethtool_ops = {
.get_settings = spider_net_ethtool_get_settings,
.get_drvinfo = spider_net_ethtool_get_drvinfo,
.get_wol = spider_net_ethtool_get_wol,
.get_msglevel = spider_net_ethtool_get_msglevel,
.set_msglevel = spider_net_ethtool_set_msglevel,
.get_link = ethtool_op_get_link,
.nway_reset = spider_net_ethtool_nway_reset,
.get_ringparam = spider_net_ethtool_get_ringparam,
.get_strings = spider_net_get_strings,
.get_sset_count = spider_net_get_sset_count,
.get_ethtool_stats = spider_net_get_ethtool_stats,
};

File diff suppressed because it is too large Load diff