Adjust ioctl function of cellular
Add SIOCGCELLNETDEV Give a uint8_t[136] for cellular to save data Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
This commit is contained in:
parent
1ced1e9f35
commit
f454dfccb2
@ -176,15 +176,6 @@ struct can_ioctl_filter_s
|
||||
uint8_t fprio; /* See CAN_MSGPRIO_* definitions */
|
||||
};
|
||||
|
||||
/* Structure passed to get or set the cellular network device features */
|
||||
|
||||
struct cell_ioctl_data_s
|
||||
{
|
||||
uint8_t mdp_chnidx; /* MDP(Multi Data Path) channel idx bound to this network device */
|
||||
uint8_t sim_id; /* Sim ID in dual sim system */
|
||||
uint8_t cell_id; /* Cell Identification in mobile phone networks */
|
||||
};
|
||||
|
||||
/* There are two forms of the I/F request structure.
|
||||
* One for IPv6 and one for IPv4.
|
||||
* Notice that they are (and must be) cast compatible and really different
|
||||
@ -211,7 +202,6 @@ struct lifreq
|
||||
struct mii_ioctl_data_s lifru_mii_data; /* MII request data */
|
||||
struct can_ioctl_data_s lifru_can_data; /* CAN bitrate request data */
|
||||
struct can_ioctl_filter_s lifru_can_filter; /* CAN filter request data */
|
||||
struct cell_ioctl_data_s lifru_cell_data; /* Cellular network data */
|
||||
} lifr_ifru;
|
||||
};
|
||||
|
||||
@ -265,7 +255,6 @@ struct ifreq
|
||||
struct mii_ioctl_data_s ifru_mii_data; /* MII request data */
|
||||
struct can_ioctl_data_s ifru_can_data; /* CAN bitrate request data */
|
||||
struct can_ioctl_filter_s ifru_can_filter; /* CAN filter request data */
|
||||
struct cell_ioctl_data_s ifru_cell_data; /* Cellular network data */
|
||||
} ifr_ifru;
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,7 @@
|
||||
#define _PKTRADIOBASE (0x3500) /* Packet radio ioctl commands */
|
||||
#define _LTEBASE (0x3600) /* LTE device ioctl commands */
|
||||
#define _VIDIOCBASE (0x3700) /* Video device ioctl commands */
|
||||
#define _CELLIOCBASE (0x3800) /* Cellular device ioctl commands */
|
||||
#define _WLIOCBASE (0x8b00) /* Wireless modules ioctl network commands */
|
||||
|
||||
/* boardctl() commands share the same number space */
|
||||
@ -605,6 +606,11 @@
|
||||
#define _VIDIOCVALID(c) (_IOC_TYPE(c)==_VIDIOCBASE)
|
||||
#define _VIDIOC(nr) _IOC(_VIDIOCBASE,nr)
|
||||
|
||||
/* cellularctl() command definitions ****************************************/
|
||||
|
||||
#define _CELLIOCVALID(c) (_IOC_TYPE(c)==_CELLIOCBASE)
|
||||
#define _CELLIOC(nr) _IOC(_CELLIOCBASE,nr)
|
||||
|
||||
/* Wireless driver network ioctl definitions ********************************/
|
||||
|
||||
/* (see nuttx/include/wireless/wireless.h */
|
||||
|
@ -121,10 +121,6 @@
|
||||
#define SIOCACANSTDFILTER _SIOC(0x0030) /* Add hardware-level standard ID filter */
|
||||
#define SIOCDCANSTDFILTER _SIOC(0x0031) /* Delete hardware-level standard ID filter */
|
||||
|
||||
/* Cellular net driver ******************************************************/
|
||||
|
||||
#define SIOCSCELLNETDEV _SIOC(0x0032) /* Set cellular Netowrk Interface */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
85
include/nuttx/wireless/cellular/cellular.h
Normal file
85
include/nuttx/wireless/cellular/cellular.h
Normal file
@ -0,0 +1,85 @@
|
||||
/************************************************************************************
|
||||
* include/nuttx/wireless/cellular/cellular.h
|
||||
* Cellular network device commands
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CELLULAR_CELLULAR_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CELLULAR_CELLULAR_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Sizing parameters */
|
||||
|
||||
#define IFCELLDEVPARAMSIZ 136 /* Big enough to store cellelur net paramters */
|
||||
|
||||
/* Network Driver IOCTL Commands ****************************************************/
|
||||
|
||||
/* Use of these IOCTL commands requires a socket descriptor created by the socket()
|
||||
* interface.
|
||||
*/
|
||||
|
||||
#define SIOCSCELLNETDEV _CELLIOC(0x0000) /* Set info in dev */
|
||||
#define SIOCGCELLNETDEV _CELLIOC(0x0001) /* Get info in dev */
|
||||
|
||||
/* cell member for struct icellreq */
|
||||
|
||||
#define ifr_cellinfo icellr_ifru.icellru_info;
|
||||
#define ifr_celldata icellr_ifru.ioctl_param;
|
||||
|
||||
/************************************************************************************
|
||||
* Public Type Definitions
|
||||
************************************************************************************/
|
||||
|
||||
struct cellnetinfo_s
|
||||
{
|
||||
uint8_t mdp_chnidx; /* MDP(Multi Data Path) channel idx */
|
||||
uint8_t sim_id; /* Sim ID in dual sim system */
|
||||
uint8_t cell_id; /* Cell Identification in mobile phone networks */
|
||||
uint8_t if_type;
|
||||
};
|
||||
|
||||
/* This is the structure used to exchange data in cellular IOCTLs.
|
||||
* same as 'struct ifreq', but defined for use with cellular IOCTLs.
|
||||
*/
|
||||
|
||||
struct icellreq
|
||||
{
|
||||
char ifr_name[IFNAMSIZ]; /* Interface name, e.g. "cell0" */
|
||||
union
|
||||
{
|
||||
struct cellnetinfo_s icellru_info;
|
||||
uint8_t ioctl_param[IFCELLDEVPARAMSIZ];
|
||||
}icellr_ifru;
|
||||
};
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_WIRELESS_CELLULAR_CELLULAR_H */
|
@ -67,6 +67,10 @@
|
||||
# include <nuttx/wireless/pktradio.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_CELLULAR
|
||||
# include <nuttx/wireless/cellular/cellular.h>
|
||||
#endif
|
||||
|
||||
#include "arp/arp.h"
|
||||
#include "socket/socket.h"
|
||||
#include "netdev/netdev.h"
|
||||
@ -544,6 +548,47 @@ static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd,
|
||||
}
|
||||
#endif /* HAVE_PKTRADIO_IOCTL */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_cell_ioctl
|
||||
*
|
||||
* Description:
|
||||
* Perform cell ioctl operations.
|
||||
*
|
||||
* Parameters:
|
||||
* psock Socket structure
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
*
|
||||
* Return:
|
||||
* >=0 on success (positive non-zero values are cmd-specific)
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
static int netdev_cell_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR struct icellreq *req)
|
||||
{
|
||||
FAR struct net_driver_s *dev = NULL;
|
||||
int ret = -ENOTTY;
|
||||
|
||||
ninfo("cmd: %d\n", cmd);
|
||||
net_lock();
|
||||
|
||||
if (_CELLIOCVALID(cmd))
|
||||
{
|
||||
dev = netdev_findbyname(req->ifr_name);
|
||||
if (dev && dev->d_ioctl)
|
||||
{
|
||||
ret = dev->d_ioctl(dev, cmd, (unsigned long)(uintptr_t)req);
|
||||
}
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_wifr_ioctl
|
||||
*
|
||||
@ -661,7 +706,6 @@ static ssize_t net_ioctl_ifreq_arglen(int cmd)
|
||||
case SIOCDCANEXTFILTER:
|
||||
case SIOCACANSTDFILTER:
|
||||
case SIOCDCANSTDFILTER:
|
||||
case SIOCSCELLNETDEV:
|
||||
case SIOCSIFNAME:
|
||||
case SIOCGIFNAME:
|
||||
case SIOCGIFINDEX:
|
||||
@ -1078,22 +1122,6 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
case SIOCSCELLNETDEV: /* set params for cellular network devices */
|
||||
if (dev->d_ioctl)
|
||||
{
|
||||
FAR struct cell_ioctl_data_s *cell_netdev_data =
|
||||
&req->ifr_ifru.ifru_cell_data;
|
||||
ret = dev->d_ioctl(dev, cmd,
|
||||
(unsigned long)(uintptr_t)cell_netdev_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
@ -1714,6 +1742,16 @@ int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
/* Check for a cellular network command */
|
||||
|
||||
if (ret == -ENOTTY)
|
||||
{
|
||||
ret = netdev_cell_ioctl(psock, cmd,
|
||||
(FAR struct icellreq *)(uintptr_t)arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IEEE802154_IOCTL
|
||||
/* Check for a IEEE802.15.4 network device IOCTL command */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user