#include <pcmcia/ds.h>
#include <pcmcia/mem_op.h>
-#ifdef CONFIG_NET_PCMCIA_RADIO
#include <linux/wireless.h>
#include <asm/io.h>
typedef struct iw_statistics iw_stats;
typedef struct iw_quality iw_qual;
typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
-#endif /* CONFIG_NET_PCMCIA_RADIO */
#include "rayctl.h"
#include "ray_cs.h"
static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
static void ray_update_multi_list(struct net_device *dev, int all);
-static int translate_frame(ray_dev_t *local, struct tx_msg *ptx,
+static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
unsigned char *data, int len);
-static void ray_build_header(ray_dev_t *local, struct tx_msg *ptx, UCHAR msg_type,
+static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type,
unsigned char *data);
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */
/* Prototypes for interrpt time functions **********************************/
static irqreturn_t ray_interrupt (int reg, void *dev_id, struct pt_regs *regs);
static void clear_interrupt(ray_dev_t *local);
-static void rx_deauthenticate(ray_dev_t *local, struct rcs *prcs,
+static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len);
static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len);
-static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs *prcs);
-static void release_frag_chain(ray_dev_t *local, struct rcs *prcs);
-static void rx_authenticate(ray_dev_t *local, struct rcs *prcs,
+static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs);
+static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs);
+static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len);
-static void rx_data(struct net_device *dev, struct rcs *prcs, unsigned int pkt_addr,
+static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned int pkt_addr,
int rx_len);
static void associate(ray_dev_t *local);
CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win));
mem.CardOffset = 0x0000; mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
- local->sram = (UCHAR *)(ioremap(req.Base,req.Size));
+ local->sram = ioremap(req.Base,req.Size);
/*** Set up 16k window for shared memory (receive buffer) ***************/
req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->rmem_handle));
mem.CardOffset = 0x8000; mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem));
- local->rmem = (UCHAR *)(ioremap(req.Base,req.Size));
+ local->rmem = ioremap(req.Base,req.Size);
/*** Set up window for attribute memory ***********************************/
req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->amem_handle));
mem.CardOffset = 0x0000; mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem));
- local->amem = (UCHAR *)(ioremap(req.Base,req.Size));
+ local->amem = ioremap(req.Base,req.Size);
DEBUG(3,"ray_config sram=%p\n",local->sram);
DEBUG(3,"ray_config rmem=%p\n",local->rmem);
ray_release(link);
} /* ray_config */
+
+static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
+{
+ return dev->sram + CCS_BASE;
+}
+
+static inline struct rcs __iomem *rcs_base(ray_dev_t *dev)
+{
+ /*
+ * This looks nonsensical, since there is a separate
+ * RCS_BASE. But the difference between a "struct rcs"
+ * and a "struct ccs" ends up being in the _index_ off
+ * the base, so the base pointer is the same for both
+ * ccs/rcs.
+ */
+ return dev->sram + CCS_BASE;
+}
+
/*===========================================================================*/
static int ray_init(struct net_device *dev)
{
int i;
UCHAR *p;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
ray_dev_t *local = (ray_dev_t *)dev->priv;
dev_link_t *link = local->finder;
DEBUG(1, "ray_init(0x%p)\n", dev);
local->tib_length = local->startup_res.tib_length;
DEBUG(2,"ray_init tib_length = 0x%02x\n", local->tib_length);
/* Initialize CCS's to buffer free state */
- pccs = (struct ccs *)(local->sram + CCS_BASE);
+ pccs = ccs_base(local);
for (i=0; i<NUMBER_OF_CCS; i++) {
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
}
{
int ccsindex;
ray_dev_t *local = (ray_dev_t *)dev->priv;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
dev_link_t *link = local->finder;
DEBUG(1,"dl_startup_params entered\n");
/* Fill in the CCS fields for the ECF */
if ((ccsindex = get_free_ccs(local)) < 0) return -1;
local->dl_param_ccs = ccsindex;
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd);
DEBUG(2,"dl_startup_params start ccsindex = %d\n", local->dl_param_ccs);
/* Interrupt the firmware to process the command */
static void verify_dl_startup(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
- struct ccs *pccs = ((struct ccs *)(local->sram + CCS_BASE)) + local->dl_param_ccs;
+ struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
UCHAR status;
dev_link_t *link = local->finder;
static void start_net(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
int ccsindex;
dev_link_t *link = local->finder;
if (!(link->state & DEV_PRESENT)) {
}
/* Fill in the CCS fields for the ECF */
if ((ccsindex = get_free_ccs(local)) < 0) return;
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
writeb(CCS_START_NETWORK, &pccs->cmd);
writeb(0, &pccs->var.start_network.update_param);
/* Interrupt the firmware to process the command */
{
ray_dev_t *local = (ray_dev_t *)data;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
int ccsindex;
dev_link_t *link = local->finder;
}
/* Fill in the CCS fields for the ECF */
if ((ccsindex = get_free_ccs(local)) < 0) return;
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
writeb(CCS_JOIN_NETWORK, &pccs->cmd);
writeb(0, &pccs->var.join_network.update_param);
writeb(0, &pccs->var.join_network.net_initiated);
UCHAR msg_type)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
int ccsindex;
int offset;
- struct tx_msg *ptx; /* Address of xmit buffer in PC space */
+ struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
short int addr; /* Address of xmit buffer in card space */
DEBUG(3,"ray_hw_xmit(data=%p, len=%d, dev=%p)\n",data,len,dev);
local->stats.tx_packets++;
}
- ptx = (struct tx_msg *)(local->sram + addr);
+ ptx = local->sram + addr;
ray_build_header(local, ptx, msg_type, data);
if (translate) {
}
/* fill in the CCS */
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
len += TX_HEADER_LENGTH + offset;
writeb(CCS_TX_REQUEST, &pccs->cmd);
writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]);
return XMIT_OK;
} /* end ray_hw_xmit */
/*===========================================================================*/
-static int translate_frame(ray_dev_t *local, struct tx_msg *ptx, unsigned char *data,
+static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, unsigned char *data,
int len)
{
unsigned short int proto = ((struct ethhdr *)data)->h_proto;
if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */
DEBUG(3,"ray_cs translate_frame DIX II\n");
/* Copy LLC header to card buffer */
- memcpy_toio((UCHAR *)&ptx->var, eth2_llc, sizeof(eth2_llc));
- memcpy_toio( ((UCHAR *)&ptx->var) + sizeof(eth2_llc), (UCHAR *)&proto, 2);
+ memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
+ memcpy_toio( ((void __iomem *)&ptx->var) + sizeof(eth2_llc), (UCHAR *)&proto, 2);
if ((proto == 0xf380) || (proto == 0x3781)) {
/* This is the selective translation table, only 2 entries */
- writeb(0xf8, (UCHAR *) &((struct snaphdr_t *)ptx->var)->org[3]);
+ writeb(0xf8, &((struct snaphdr_t __iomem *)ptx->var)->org[3]);
}
/* Copy body of ethernet packet without ethernet header */
- memcpy_toio((UCHAR *)&ptx->var + sizeof(struct snaphdr_t), \
+ memcpy_toio((void __iomem *)&ptx->var + sizeof(struct snaphdr_t), \
data + ETH_HLEN, len - ETH_HLEN);
return (int) sizeof(struct snaphdr_t) - ETH_HLEN;
}
DEBUG(3,"ray_cs translate_frame 802\n");
if (proto == 0xffff) { /* evil netware IPX 802.3 without LLC */
DEBUG(3,"ray_cs translate_frame evil IPX\n");
- memcpy_toio((UCHAR *)&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
+ memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
return 0 - ETH_HLEN;
}
- memcpy_toio((UCHAR *)&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
+ memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
return 0 - ETH_HLEN;
}
/* TBD do other frame types */
} /* end translate_frame */
/*===========================================================================*/
-static void ray_build_header(ray_dev_t *local, struct tx_msg *ptx, UCHAR msg_type,
+static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type,
unsigned char *data)
{
writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
{
ray_dev_t * local = (ray_dev_t *) dev->priv;
dev_link_t *link = local->finder;
- struct status *p = (struct status *)(local->sram + STATUS_BASE);
+ struct status __iomem *p = local->sram + STATUS_BASE;
if(local == (ray_dev_t *) NULL)
return (iw_stats *) NULL;
static int get_free_tx_ccs(ray_dev_t *local)
{
int i;
- struct ccs *pccs = (struct ccs *)(local->sram + CCS_BASE);
+ struct ccs __iomem *pccs = ccs_base(local);
dev_link_t *link = local->finder;
if (!(link->state & DEV_PRESENT)) {
static int get_free_ccs(ray_dev_t *local)
{
int i;
- struct ccs *pccs = (struct ccs *)(local->sram + CCS_BASE);
+ struct ccs __iomem *pccs = ccs_base(local);
dev_link_t *link = local->finder;
if (!(link->state & DEV_PRESENT)) {
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
dev_link_t *link = local->finder;
- struct status *p = (struct status *)(local->sram + STATUS_BASE);
+ struct status __iomem *p = local->sram + STATUS_BASE;
if (!(link->state & DEV_PRESENT)) {
DEBUG(2,"ray_cs net_device_stats - device not present\n");
return &local->stats;
dev_link_t *link = local->finder;
int ccsindex;
int i;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
if (!(link->state & DEV_PRESENT)) {
DEBUG(2,"ray_update_parm - device not present\n");
DEBUG(0,"ray_update_parm - No free ccs\n");
return;
}
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
writeb(CCS_UPDATE_PARAMS, &pccs->cmd);
writeb(objid, &pccs->var.update_param.object_id);
writeb(1, &pccs->var.update_param.number_objects);
{
struct dev_mc_list *dmi, **dmip;
int ccsindex;
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
int i = 0;
ray_dev_t *local = (ray_dev_t *)dev->priv;
dev_link_t *link = local->finder;
- UCHAR *p = local->sram + HOST_TO_ECF_BASE;
+ void __iomem *p = local->sram + HOST_TO_ECF_BASE;
if (!(link->state & DEV_PRESENT)) {
DEBUG(2,"ray_update_multi_list - device not present\n");
DEBUG(1,"ray_update_multi - No free ccs\n");
return;
}
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd);
if (all) {
struct net_device *dev = (struct net_device *)dev_id;
dev_link_t *link;
ray_dev_t *local;
- struct ccs *pccs;
- struct rcs *prcs;
+ struct ccs __iomem *pccs;
+ struct rcs __iomem *prcs;
UCHAR rcsindex;
UCHAR tmp;
UCHAR cmd;
DEBUG(2,"ray_cs interrupt from device not present or suspended.\n");
return IRQ_NONE;
}
- rcsindex = readb(&((struct scb *)(local->sram))->rcs_index);
+ rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS))
{
}
if (rcsindex < NUMBER_OF_CCS) /* If it's a returned CCS */
{
- pccs = ((struct ccs *) (local->sram + CCS_BASE)) + rcsindex;
+ pccs = ccs_base(local) + rcsindex;
cmd = readb(&pccs->cmd);
status = readb(&pccs->buffer_status);
switch (cmd)
}
else /* It's an RCS */
{
- prcs = ((struct rcs *)(local->sram + CCS_BASE)) + rcsindex;
+ prcs = rcs_base(local) + rcsindex;
switch (readb(&prcs->interrupt_id))
{
return IRQ_HANDLED;
} /* ray_interrupt */
/*===========================================================================*/
-static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs *prcs)
+static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs)
{
int rx_len;
unsigned int pkt_addr;
- UCHAR *pmsg;
+ void __iomem *pmsg;
DEBUG(4,"ray_rx process rx packet\n");
/* Calculate address of packet within Rx buffer */
} /* end ray_rx */
/*===========================================================================*/
-static void rx_data(struct net_device *dev, struct rcs *prcs, unsigned int pkt_addr,
+static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned int pkt_addr,
int rx_len)
{
struct sk_buff *skb = NULL;
- struct rcs *prcslink = prcs;
+ struct rcs __iomem *prcslink = prcs;
ray_dev_t *local = dev->priv;
UCHAR *rx_ptr;
int total_len;
+ readb(&prcslink->var.rx_packet.rx_data_length[1]);
if (readb(&prcslink->var.rx_packet.next_frag_rcs_index) == 0xFF
|| tmp < 0) break;
- prcslink = ((struct rcs *)(local->sram + CCS_BASE))
+ prcslink = rcs_base(local)
+ readb(&prcslink->link_field);
} while (1);
prcslink = prcs;
DEBUG(1,"ray_cs rx_data in fragment loop\n");
do {
- prcslink = ((struct rcs *)(local->sram + CCS_BASE))
+ prcslink = rcs_base(local)
+ readb(&prcslink->var.rx_packet.next_frag_rcs_index);
rx_len = (( readb(&prcslink->var.rx_packet.rx_data_length[0]) << 8)
+ readb(&prcslink->var.rx_packet.rx_data_length[1]))
return length;
}
/*===========================================================================*/
-static void release_frag_chain(ray_dev_t *local, struct rcs* prcs)
+static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs)
{
- struct rcs *prcslink = prcs;
+ struct rcs __iomem *prcslink = prcs;
int tmp = 17;
unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index);
DEBUG(1,"ray_cs interrupt bad rcsindex = 0x%x\n",rcsindex);
break;
}
- prcslink = ((struct rcs *)(local->sram + CCS_BASE)) + rcsindex;
+ prcslink = rcs_base(local) + rcsindex;
rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index);
}
writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
local->authentication_state = AWAITING_RESPONSE;
} /* end authenticate */
/*===========================================================================*/
-static void rx_authenticate(ray_dev_t *local, struct rcs *prcs,
+static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len)
{
UCHAR buff[256];
/*===========================================================================*/
static void associate(ray_dev_t *local)
{
- struct ccs *pccs;
+ struct ccs __iomem *pccs;
dev_link_t *link = local->finder;
struct net_device *dev = link->priv;
int ccsindex;
return;
}
DEBUG(1,"ray_cs Starting association with access point\n");
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
/* fill in the CCS */
writeb(CCS_START_ASSOCIATION, &pccs->cmd);
/* Interrupt the firmware to process the command */
} /* end associate */
/*===========================================================================*/
-static void rx_deauthenticate(ray_dev_t *local, struct rcs *prcs,
+static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len)
{
/* UCHAR buff[256];
static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
{
int addr;
- struct ccs *pccs;
- struct tx_msg *ptx;
+ struct ccs __iomem *pccs;
+ struct tx_msg __iomem *ptx;
int ccsindex;
/* If no tx buffers available, return */
return -1;
}
- pccs = ((struct ccs *)(local->sram + CCS_BASE)) + ccsindex;
+ pccs = ccs_base(local) + ccsindex;
/* Address in card space */
addr = TX_BUF_BASE + (ccsindex << 11);
writeb(TX_AUTHENTICATE_LENGTH_LSB,pccs->var.tx_request.tx_data_length + 1);
writeb(0, &pccs->var.tx_request.pow_sav_mode);
- ptx = (struct tx_msg *)(local->sram + addr);
+ ptx = local->sram + addr;
/* fill in the mac header */
writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1);
writeb(0, &ptx->mac.frame_ctl_2);
{
DEBUG(0, "ray_cs: cleanup_module\n");
-
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("ray_cs", proc_root_driver);
-#endif
-
- pcmcia_unregister_driver(&ray_driver);
- while (dev_list != NULL)
- ray_detach(dev_list);
-
#ifdef CONFIG_PROC_FS
remove_proc_entry("driver/ray_cs/ray_cs", NULL);
remove_proc_entry("driver/ray_cs/essid", NULL);
remove_proc_entry("driver/ray_cs/translate", NULL);
remove_proc_entry("driver/ray_cs", NULL);
#endif
+
+ pcmcia_unregister_driver(&ray_driver);
+ while (dev_list != NULL)
+ ray_detach(dev_list);
} /* exit_ray_cs */
module_init(init_ray_cs);