mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-19 09:52:31 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -220,6 +220,9 @@ struct tun_struct {
|
||||
struct tun_prog __rcu *steering_prog;
|
||||
struct tun_prog __rcu *filter_prog;
|
||||
struct ethtool_link_ksettings link_ksettings;
|
||||
/* init args */
|
||||
struct file *file;
|
||||
struct ifreq *ifr;
|
||||
};
|
||||
|
||||
struct veth {
|
||||
@@ -227,6 +230,9 @@ struct veth {
|
||||
__be16 h_vlan_TCI;
|
||||
};
|
||||
|
||||
static void tun_flow_init(struct tun_struct *tun);
|
||||
static void tun_flow_uninit(struct tun_struct *tun);
|
||||
|
||||
static int tun_napi_receive(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct tun_file *tfile = container_of(napi, struct tun_file, napi);
|
||||
@@ -279,6 +285,12 @@ static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile,
|
||||
}
|
||||
}
|
||||
|
||||
static void tun_napi_enable(struct tun_file *tfile)
|
||||
{
|
||||
if (tfile->napi_enabled)
|
||||
napi_enable(&tfile->napi);
|
||||
}
|
||||
|
||||
static void tun_napi_disable(struct tun_file *tfile)
|
||||
{
|
||||
if (tfile->napi_enabled)
|
||||
@@ -640,7 +652,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
|
||||
tun = rtnl_dereference(tfile->tun);
|
||||
|
||||
if (tun && clean) {
|
||||
tun_napi_disable(tfile);
|
||||
if (!tfile->detached)
|
||||
tun_napi_disable(tfile);
|
||||
tun_napi_del(tfile);
|
||||
}
|
||||
|
||||
@@ -659,8 +672,10 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
|
||||
if (clean) {
|
||||
RCU_INIT_POINTER(tfile->tun, NULL);
|
||||
sock_put(&tfile->sk);
|
||||
} else
|
||||
} else {
|
||||
tun_disable_queue(tun, tfile);
|
||||
tun_napi_disable(tfile);
|
||||
}
|
||||
|
||||
synchronize_net();
|
||||
tun_flow_delete_by_queue(tun, tun->numqueues + 1);
|
||||
@@ -683,7 +698,6 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
|
||||
if (tun)
|
||||
xdp_rxq_info_unreg(&tfile->xdp_rxq);
|
||||
ptr_ring_cleanup(&tfile->tx_ring, tun_ptr_free);
|
||||
sock_put(&tfile->sk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,6 +713,9 @@ static void tun_detach(struct tun_file *tfile, bool clean)
|
||||
if (dev)
|
||||
netdev_state_change(dev);
|
||||
rtnl_unlock();
|
||||
|
||||
if (clean)
|
||||
sock_put(&tfile->sk);
|
||||
}
|
||||
|
||||
static void tun_detach_all(struct net_device *dev)
|
||||
@@ -733,6 +750,7 @@ static void tun_detach_all(struct net_device *dev)
|
||||
sock_put(&tfile->sk);
|
||||
}
|
||||
list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) {
|
||||
tun_napi_del(tfile);
|
||||
tun_enable_queue(tfile);
|
||||
tun_queue_purge(tfile);
|
||||
xdp_rxq_info_unreg(&tfile->xdp_rxq);
|
||||
@@ -813,6 +831,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file,
|
||||
|
||||
if (tfile->detached) {
|
||||
tun_enable_queue(tfile);
|
||||
tun_napi_enable(tfile);
|
||||
} else {
|
||||
sock_hold(&tfile->sk);
|
||||
tun_napi_init(tun, tfile, napi, napi_frags);
|
||||
@@ -964,6 +983,49 @@ static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)
|
||||
|
||||
static const struct ethtool_ops tun_ethtool_ops;
|
||||
|
||||
static int tun_net_init(struct net_device *dev)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(dev);
|
||||
struct ifreq *ifr = tun->ifr;
|
||||
int err;
|
||||
|
||||
tun->pcpu_stats = netdev_alloc_pcpu_stats(struct tun_pcpu_stats);
|
||||
if (!tun->pcpu_stats)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&tun->lock);
|
||||
|
||||
err = security_tun_dev_alloc_security(&tun->security);
|
||||
if (err < 0) {
|
||||
free_percpu(tun->pcpu_stats);
|
||||
return err;
|
||||
}
|
||||
|
||||
tun_flow_init(tun);
|
||||
|
||||
dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
|
||||
TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
|
||||
NETIF_F_HW_VLAN_STAG_TX;
|
||||
dev->features = dev->hw_features | NETIF_F_LLTX;
|
||||
dev->vlan_features = dev->features &
|
||||
~(NETIF_F_HW_VLAN_CTAG_TX |
|
||||
NETIF_F_HW_VLAN_STAG_TX);
|
||||
|
||||
tun->flags = (tun->flags & ~TUN_FEATURES) |
|
||||
(ifr->ifr_flags & TUN_FEATURES);
|
||||
|
||||
INIT_LIST_HEAD(&tun->disabled);
|
||||
err = tun_attach(tun, tun->file, false, ifr->ifr_flags & IFF_NAPI,
|
||||
ifr->ifr_flags & IFF_NAPI_FRAGS, false);
|
||||
if (err < 0) {
|
||||
tun_flow_uninit(tun);
|
||||
security_tun_dev_free_security(tun->security);
|
||||
free_percpu(tun->pcpu_stats);
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Net device detach from fd. */
|
||||
static void tun_net_uninit(struct net_device *dev)
|
||||
{
|
||||
@@ -1205,6 +1267,7 @@ static int tun_net_change_carrier(struct net_device *dev, bool new_carrier)
|
||||
}
|
||||
|
||||
static const struct net_device_ops tun_netdev_ops = {
|
||||
.ndo_init = tun_net_init,
|
||||
.ndo_uninit = tun_net_uninit,
|
||||
.ndo_open = tun_net_open,
|
||||
.ndo_stop = tun_net_close,
|
||||
@@ -1285,6 +1348,7 @@ static int tun_xdp_tx(struct net_device *dev, struct xdp_buff *xdp)
|
||||
}
|
||||
|
||||
static const struct net_device_ops tap_netdev_ops = {
|
||||
.ndo_init = tun_net_init,
|
||||
.ndo_uninit = tun_net_uninit,
|
||||
.ndo_open = tun_net_open,
|
||||
.ndo_stop = tun_net_close,
|
||||
@@ -1325,7 +1389,7 @@ static void tun_flow_uninit(struct tun_struct *tun)
|
||||
#define MAX_MTU 65535
|
||||
|
||||
/* Initialize net device. */
|
||||
static void tun_net_init(struct net_device *dev)
|
||||
static void tun_net_initialize(struct net_device *dev)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(dev);
|
||||
|
||||
@@ -1413,7 +1477,8 @@ static struct sk_buff *tun_napi_alloc_frags(struct tun_file *tfile,
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (it->nr_segs > MAX_SKB_FRAGS + 1)
|
||||
if (it->nr_segs > MAX_SKB_FRAGS + 1 ||
|
||||
len > (ETH_MAX_MTU - NET_SKB_PAD - NET_IP_ALIGN))
|
||||
return ERR_PTR(-EMSGSIZE);
|
||||
|
||||
local_bh_disable();
|
||||
@@ -1923,17 +1988,25 @@ drop:
|
||||
skb_headlen(skb));
|
||||
|
||||
if (unlikely(headlen > skb_headlen(skb))) {
|
||||
WARN_ON_ONCE(1);
|
||||
err = -ENOMEM;
|
||||
this_cpu_inc(tun->pcpu_stats->rx_dropped);
|
||||
napi_busy:
|
||||
napi_free_frags(&tfile->napi);
|
||||
rcu_read_unlock();
|
||||
mutex_unlock(&tfile->napi_mutex);
|
||||
WARN_ON(1);
|
||||
return -ENOMEM;
|
||||
return err;
|
||||
}
|
||||
|
||||
local_bh_disable();
|
||||
napi_gro_frags(&tfile->napi);
|
||||
local_bh_enable();
|
||||
if (likely(napi_schedule_prep(&tfile->napi))) {
|
||||
local_bh_disable();
|
||||
napi_gro_frags(&tfile->napi);
|
||||
napi_complete(&tfile->napi);
|
||||
local_bh_enable();
|
||||
} else {
|
||||
err = -EBUSY;
|
||||
goto napi_busy;
|
||||
}
|
||||
mutex_unlock(&tfile->napi_mutex);
|
||||
} else if (tfile->napi_enabled) {
|
||||
struct sk_buff_head *queue = &tfile->sk.sk_write_queue;
|
||||
@@ -2257,10 +2330,6 @@ static void tun_free_netdev(struct net_device *dev)
|
||||
BUG_ON(!(list_empty(&tun->disabled)));
|
||||
|
||||
free_percpu(tun->pcpu_stats);
|
||||
/* We clear pcpu_stats so that tun_set_iff() can tell if
|
||||
* tun_free_netdev() has been called from register_netdevice().
|
||||
*/
|
||||
tun->pcpu_stats = NULL;
|
||||
|
||||
tun_flow_uninit(tun);
|
||||
security_tun_dev_free_security(tun->security);
|
||||
@@ -2499,7 +2568,8 @@ static int tun_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
|
||||
if (!tun)
|
||||
return -EBADFD;
|
||||
|
||||
if (ctl && (ctl->type == TUN_MSG_PTR)) {
|
||||
if (m->msg_controllen == sizeof(struct tun_msg_ctl) &&
|
||||
ctl && ctl->type == TUN_MSG_PTR) {
|
||||
struct tun_page tpage;
|
||||
int n = ctl->num;
|
||||
int flush = 0;
|
||||
@@ -2772,41 +2842,16 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
|
||||
tun->rx_batched = 0;
|
||||
RCU_INIT_POINTER(tun->steering_prog, NULL);
|
||||
|
||||
tun->pcpu_stats = netdev_alloc_pcpu_stats(struct tun_pcpu_stats);
|
||||
if (!tun->pcpu_stats) {
|
||||
err = -ENOMEM;
|
||||
goto err_free_dev;
|
||||
}
|
||||
tun->ifr = ifr;
|
||||
tun->file = file;
|
||||
|
||||
spin_lock_init(&tun->lock);
|
||||
|
||||
err = security_tun_dev_alloc_security(&tun->security);
|
||||
if (err < 0)
|
||||
goto err_free_stat;
|
||||
|
||||
tun_net_init(dev);
|
||||
tun_flow_init(tun);
|
||||
|
||||
dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
|
||||
TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
|
||||
NETIF_F_HW_VLAN_STAG_TX;
|
||||
dev->features = dev->hw_features | NETIF_F_LLTX;
|
||||
dev->vlan_features = dev->features &
|
||||
~(NETIF_F_HW_VLAN_CTAG_TX |
|
||||
NETIF_F_HW_VLAN_STAG_TX);
|
||||
|
||||
tun->flags = (tun->flags & ~TUN_FEATURES) |
|
||||
(ifr->ifr_flags & TUN_FEATURES);
|
||||
|
||||
INIT_LIST_HEAD(&tun->disabled);
|
||||
err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI,
|
||||
ifr->ifr_flags & IFF_NAPI_FRAGS, false);
|
||||
if (err < 0)
|
||||
goto err_free_flow;
|
||||
tun_net_initialize(dev);
|
||||
|
||||
err = register_netdevice(tun->dev);
|
||||
if (err < 0)
|
||||
goto err_detach;
|
||||
if (err < 0) {
|
||||
free_netdev(dev);
|
||||
return err;
|
||||
}
|
||||
/* free_netdev() won't check refcnt, to aovid race
|
||||
* with dev_put() we need publish tun after registration.
|
||||
*/
|
||||
@@ -2823,24 +2868,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
|
||||
|
||||
strcpy(ifr->ifr_name, tun->dev->name);
|
||||
return 0;
|
||||
|
||||
err_detach:
|
||||
tun_detach_all(dev);
|
||||
/* We are here because register_netdevice() has failed.
|
||||
* If register_netdevice() already called tun_free_netdev()
|
||||
* while dealing with the error, tun->pcpu_stats has been cleared.
|
||||
*/
|
||||
if (!tun->pcpu_stats)
|
||||
goto err_free_dev;
|
||||
|
||||
err_free_flow:
|
||||
tun_flow_uninit(tun);
|
||||
security_tun_dev_free_security(tun->security);
|
||||
err_free_stat:
|
||||
free_percpu(tun->pcpu_stats);
|
||||
err_free_dev:
|
||||
free_netdev(dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
|
||||
|
||||
Reference in New Issue
Block a user