📄 wavelan_cs.c
字号:
/* Increment interval counter */ (lp->his_sum[i])++;}#endif /* HISTOGRAM */static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info){ strncpy(info->driver, "wavelan_cs", sizeof(info->driver)-1);}static struct ethtool_ops ops = { .get_drvinfo = wl_get_drvinfo};/*------------------------------------------------------------------*//* * Wireless Handler : get protocol name */static int wavelan_get_name(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ strcpy(wrqu->name, "WaveLAN"); return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set NWID */static int wavelan_set_nwid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); psa_t psa; mm_t m; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Set NWID in WaveLAN. */ if (!wrqu->nwid.disabled) { /* Set NWID in psa */ psa.psa_nwid[0] = (wrqu->nwid.value & 0xFF00) >> 8; psa.psa_nwid[1] = wrqu->nwid.value & 0xFF; psa.psa_nwid_select = 0x01; psa_write(dev, (char *) psa.psa_nwid - (char *) &psa, (unsigned char *) psa.psa_nwid, 3); /* Set NWID in mmc. */ m.w.mmw_netw_id_l = psa.psa_nwid[1]; m.w.mmw_netw_id_h = psa.psa_nwid[0]; mmc_write(base, (char *) &m.w.mmw_netw_id_l - (char *) &m, (unsigned char *) &m.w.mmw_netw_id_l, 2); mmc_out(base, mmwoff(0, mmw_loopt_sel), 0x00); } else { /* Disable NWID in the psa. */ psa.psa_nwid_select = 0x00; psa_write(dev, (char *) &psa.psa_nwid_select - (char *) &psa, (unsigned char *) &psa.psa_nwid_select, 1); /* Disable NWID in the mmc (no filtering). */ mmc_out(base, mmwoff(0, mmw_loopt_sel), MMW_LOOPT_SEL_DIS_NWID); } /* update the Wavelan checksum */ update_psa_checksum(dev); /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : get NWID */static int wavelan_get_nwid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ net_local *lp = netdev_priv(dev); psa_t psa; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Read the NWID. */ psa_read(dev, (char *) psa.psa_nwid - (char *) &psa, (unsigned char *) psa.psa_nwid, 3); wrqu->nwid.value = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1]; wrqu->nwid.disabled = !(psa.psa_nwid_select); wrqu->nwid.fixed = 1; /* Superfluous */ /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : set frequency */static int wavelan_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); unsigned long flags; int ret; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */ if (!(mmc_in(base, mmroff(0, mmr_fee_status)) & (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) ret = wv_set_frequency(base, &(wrqu->freq)); else ret = -EOPNOTSUPP; /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : get frequency */static int wavelan_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); psa_t psa; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). * Does it work for everybody, especially old cards? */ if (!(mmc_in(base, mmroff(0, mmr_fee_status)) & (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) { unsigned short freq; /* Ask the EEPROM to read the frequency from the first area. */ fee_read(base, 0x00, &freq, 1); wrqu->freq.m = ((freq >> 5) * 5 + 24000L) * 10000; wrqu->freq.e = 1; } else { psa_read(dev, (char *) &psa.psa_subband - (char *) &psa, (unsigned char *) &psa.psa_subband, 1); if (psa.psa_subband <= 4) { wrqu->freq.m = fixed_bands[psa.psa_subband]; wrqu->freq.e = (psa.psa_subband != 0); } else ret = -EOPNOTSUPP; } /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : set level threshold */static int wavelan_set_sens(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); psa_t psa; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Set the level threshold. */ /* We should complain loudly if wrqu->sens.fixed = 0, because we * can't set auto mode... */ psa.psa_thr_pre_set = wrqu->sens.value & 0x3F; psa_write(dev, (char *) &psa.psa_thr_pre_set - (char *) &psa, (unsigned char *) &psa.psa_thr_pre_set, 1); /* update the Wavelan checksum */ update_psa_checksum(dev); mmc_out(base, mmwoff(0, mmw_thr_pre_set), psa.psa_thr_pre_set); /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : get level threshold */static int wavelan_get_sens(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ net_local *lp = netdev_priv(dev); psa_t psa; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Read the level threshold. */ psa_read(dev, (char *) &psa.psa_thr_pre_set - (char *) &psa, (unsigned char *) &psa.psa_thr_pre_set, 1); wrqu->sens.value = psa.psa_thr_pre_set & 0x3F; wrqu->sens.fixed = 1; /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : set encryption key */static int wavelan_set_encode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); unsigned long flags; psa_t psa; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Check if capable of encryption */ if (!mmc_encr(base)) { ret = -EOPNOTSUPP; } /* Check the size of the key */ if((wrqu->encoding.length != 8) && (wrqu->encoding.length != 0)) { ret = -EINVAL; } if(!ret) { /* Basic checking... */ if (wrqu->encoding.length == 8) { /* Copy the key in the driver */ memcpy(psa.psa_encryption_key, extra, wrqu->encoding.length); psa.psa_encryption_select = 1; psa_write(dev, (char *) &psa.psa_encryption_select - (char *) &psa, (unsigned char *) &psa. psa_encryption_select, 8 + 1); mmc_out(base, mmwoff(0, mmw_encr_enable), MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE); mmc_write(base, mmwoff(0, mmw_encr_key), (unsigned char *) &psa. psa_encryption_key, 8); } /* disable encryption */ if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { psa.psa_encryption_select = 0; psa_write(dev, (char *) &psa.psa_encryption_select - (char *) &psa, (unsigned char *) &psa. psa_encryption_select, 1); mmc_out(base, mmwoff(0, mmw_encr_enable), 0); } /* update the Wavelan checksum */ update_psa_checksum(dev); } /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : get encryption key */static int wavelan_get_encode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ kio_addr_t base = dev->base_addr; net_local *lp = netdev_priv(dev); psa_t psa; unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Check if encryption is available */ if (!mmc_encr(base)) { ret = -EOPNOTSUPP; } else { /* Read the encryption key */ psa_read(dev, (char *) &psa.psa_encryption_select - (char *) &psa, (unsigned char *) &psa. psa_encryption_select, 1 + 8); /* encryption is enabled ? */ if (psa.psa_encryption_select) wrqu->encoding.flags = IW_ENCODE_ENABLED; else wrqu->encoding.flags = IW_ENCODE_DISABLED; wrqu->encoding.flags |= mmc_encr(base); /* Copy the key to the user buffer */ wrqu->encoding.length = 8; memcpy(extra, psa.psa_encryption_key, wrqu->encoding.length); } /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}#ifdef WAVELAN_ROAMING_EXT/*------------------------------------------------------------------*//* * Wireless Handler : set ESSID (domain) */static int wavelan_set_essid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ net_local *lp = netdev_priv(dev); unsigned long flags; int ret = 0; /* Disable interrupts and save flags. */ spin_lock_irqsave(&lp->spinlock, flags); /* Check if disable */ if(wrqu->data.flags == 0) lp->filter_domains = 0; else { char essid[IW_ESSID_MAX_SIZE + 1]; char * endp; /* Terminate the string */ memcpy(essid, extra, wrqu->data.length); essid[IW_ESSID_MAX_SIZE] = '\0';#ifdef DEBUG_IOCTL_INFO printk(KERN_DEBUG "SetEssid : ``%s''\n", essid);#endif /* DEBUG_IOCTL_INFO */ /* Convert to a number (note : Wavelan specific) */ lp->domain_id = simple_strtoul(essid, &endp, 16); /* Has it worked ? */ if(endp > essid) lp->filter_domains = 1; else { lp->filter_domains = 0; ret = -EINVAL; } } /* Enable interrupts and restore flags. */ spin_unlock_irqrestore(&lp->spinlock, flags); return ret;}/*------------------------------------------------------------------*//* * Wireless Handler : get ESSID (domain) */static int wavelan_get_essid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra){ net_local *lp = netdev_priv(dev); /* Is the domain ID active ? */ wrqu->data.flags = lp->filter_domains; /* Copy Domain ID into a string (Wavelan specific) */ /* Sound crazy, be we can't have a snprintf in the kernel !!! */ sprintf(extra, "%lX", lp->domain_id); extra[IW_ESSID_MAX_SIZE] = '\0'; /* Set the length */ wrqu->data.length = strlen(extra) + 1; return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set AP address */static int wavelan_set_wap(struct n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -