1
0
Fork 0
forked from nuttx/nuttx-update

Add Cellular link layer support

1.Add cellular link layer enum definition and register flow
2.Add ioctl flow to set cellular NICs parameters

Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
luojun1 2022-07-28 15:46:49 +08:00 committed by Xiang Xiao
parent 18ce70c1e7
commit ec4af00538
6 changed files with 53 additions and 5 deletions

View file

@ -172,6 +172,15 @@ 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
@ -198,6 +207,7 @@ 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;
};
@ -251,6 +261,7 @@ 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;
};

View file

@ -119,6 +119,10 @@
#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
****************************************************************************/

View file

@ -144,7 +144,8 @@ enum net_lltype_e
NET_LL_IEEE802154, /* IEEE 802.15.4 MAC */
NET_LL_PKTRADIO, /* Non-standard packet radio */
NET_LL_MBIM, /* CDC-MBIM USB host driver */
NET_LL_CAN /* CAN bus */
NET_LL_CAN, /* CAN bus */
NET_LL_CELL /* Cellular Virtual Network Device */
};
/* This defines a bitmap big enough for one bit for each socket option */

View file

@ -142,6 +142,13 @@ config NET_ETHERNET
no need to define anything special in the configuration file to use
Ethernet -- it is the default).
config NET_CELLULAR
bool "Cellular Link support"
default n
---help---
Add support for the cellular network device. Unlike Ethernet, cellular
network transmit pure IP packets.
config NET_LOOPBACK
bool "Local loopback"
select ARCH_HAVE_NETDEV_STATISTICS

View file

@ -983,7 +983,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
case SIOCMIINOTIFY: /* Set up for PHY event notifications */
if (dev->d_ioctl)
{
struct mii_ioctl_notify_s *notify =
FAR struct mii_ioctl_notify_s *notify =
&req->ifr_ifru.ifru_mii_notify;
ret = dev->d_ioctl(dev, cmd, (unsigned long)(uintptr_t)notify);
}
@ -999,7 +999,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
case SIOCSMIIREG: /* Set MII register via MDIO */
if (dev->d_ioctl)
{
struct mii_ioctl_data_s *mii_data =
FAR struct mii_ioctl_data_s *mii_data =
&req->ifr_ifru.ifru_mii_data;
ret = dev->d_ioctl(dev, cmd,
(unsigned long)(uintptr_t)mii_data);
@ -1016,7 +1016,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
case SIOCSCANBITRATE: /* Set bitrate of a CAN controller */
if (dev->d_ioctl)
{
struct can_ioctl_data_s *can_bitrate_data =
FAR struct can_ioctl_data_s *can_bitrate_data =
&req->ifr_ifru.ifru_can_data;
ret = dev->d_ioctl(dev, cmd,
(unsigned long)(uintptr_t)can_bitrate_data);
@ -1035,7 +1035,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
case SIOCDCANSTDFILTER: /* Delete a standard-ID filter */
if (dev->d_ioctl)
{
struct can_ioctl_filter_s *can_filter =
FAR struct can_ioctl_filter_s *can_filter =
&req->ifr_ifru.ifru_can_filter;
ret = dev->d_ioctl(dev, cmd,
(unsigned long)(uintptr_t)can_filter);
@ -1053,6 +1053,21 @@ 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 */
{
dev = netdev_findbyname(req->ifr_name);
if (dev && 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);
}
}
break;
#endif
default:
ret = -ENOTTY;
break;

View file

@ -58,6 +58,7 @@
#define NETDEV_WPAN_FORMAT "wpan%d"
#define NETDEV_WWAN_FORMAT "wwan%d"
#define NETDEV_CAN_FORMAT "can%d"
#define NETDEV_CELL_FORMAT "cell%d"
#if defined(CONFIG_DRIVERS_IEEE80211) /* Usually also has CONFIG_NET_ETHERNET */
# define NETDEV_DEFAULT_FORMAT NETDEV_WLAN_FORMAT
@ -346,6 +347,15 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
break;
#endif
#ifdef CONFIG_NET_CELLULAR
case NET_LL_CELL:
llhdrlen = 0;
pktsize = CONFIG_NET_ETH_PKTSIZE;
devfmt = NETDEV_CELL_FORMAT;
flags = IFF_NOARP;
break;
#endif
default:
nerr("ERROR: Unrecognized link type: %d\n", lltype);
return -EINVAL;