/** * Purpose: IOCTL entry point for network driver * * Imports: dev - device structure pointer * ifr - request structure from user via kernel * See the ifr_data member. * cmd - IOCTL code * * Exports: Error status * Response data, if any, is returned via ioctl structures * *PUBLIC***************************************************************************/ SYS_INT32 clnketh_ioctl(struct net_device *dev, struct ifreq *ifr, SYS_INT32 cmd) { SYS_INT32 status = -EINVAL; dk_context_t *dkcp = (dk_context_t *)dev ; void *arg = ifr->ifr_data ; if( !capable(CAP_SYS_ADMIN) ) { // kernel check & set permissions status = -EPERM; } else { switch( cmd ) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) case SIOCETHTOOL : status = netdev_ethtool_ioctl(dev, (SYS_VOID *)ifr->ifr_data); break ; #endif case SIOCHDRCMD : break; case SIOCCLINKDRV : // Control plane commands for the driver status = clnkioc_driver_cmd( dkcp, arg ) ; break ; case SIOCGCLINKMEM : // Reads registers/memory in c.LINK address space status = clnkioc_mem_read( dkcp, arg ) ; break ; #ifndef SONICS_ADDRESS_OF_sniff_buffer_pa #error "Sniff buffer is not defined" #else #if SONICS_ADDRESS_OF_sniff_buffer_pa // ################################################################# // Handle the case where the application (in this case the deamon) // wants to read the sniff buffer that holds the descriptors that // have been logged by the SoC. // ################################################################# case SIOCGSNIFFMEM : // Reads sniffer buffer directly in the driver status = clnkioc_sniff_read( dkcp, arg ) ; break ; #endif #endif case SIOCSCLINKMEM : // Sets registers/memory in c.LINK address space status = clnkioc_mem_write( dkcp, arg ) ; break ; case SIOCGCLNKCMD : // mbox cmmds: request with response status = clnkioc_mbox_cmd_request( dkcp, arg, 1 ) ; break ; case SIOCSCLNKCMD : // mbox cmmds: request with no response status = clnkioc_mbox_cmd_request( dkcp, arg, 0 ) ; break ; case SIOCLNKDRV : // mbox cmmds: retrieve unsol messages status = clnkioc_mbox_unsolq_retrieve( dkcp, arg ) ; break ; default: return -EOPNOTSUPP; } } return(status); }
static int awc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { switch (cmd) { case SIOCETHTOOL: return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); default: return -EOPNOTSUPP; } return 0; }
static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) { int rc = 0; switch (cmd) { case SIOCETHTOOL: rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); break; default: rc = -EOPNOTSUPP; break; } return rc; }
int adapter_ioctl(struct net_device *net, struct ifreq *rq, int cmd) { struct net_adapter *adapter = netdev_priv(net); if (adapter->halted) { dump_debug("Driver already halted. Returning Failure..."); return STATUS_UNSUCCESSFUL; } switch (cmd) { case SIOCETHTOOL: return netdev_ethtool_ioctl(net, (void *)rq->ifr_data); default: return -EOPNOTSUPP; } return 0; }