// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. * Copyright (C) 2018-2024 Linaro Ltd. */ #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/if_arp.h> #include <linux/if_rmnet.h> #include <linux/netdevice.h> #include <linux/pm_runtime.h> #include <linux/skbuff.h> #include <net/pkt_sched.h> #include <linux/remoteproc/qcom_rproc.h> #include "ipa.h" #include "ipa_endpoint.h" #include "ipa_mem.h" #include "ipa_modem.h" #include "ipa_smp2p.h" #include "ipa_table.h" #include "ipa_uc.h" #define IPA_NETDEV_NAME … #define IPA_NETDEV_TAILROOM … #define IPA_NETDEV_TIMEOUT … enum ipa_modem_state { … }; /** * struct ipa_priv - IPA network device private data * @ipa: IPA pointer * @tx: Transmit endpoint pointer * @rx: Receive endpoint pointer * @work: Work structure used to wake the modem netdev TX queue */ struct ipa_priv { … }; /** ipa_open() - Opens the modem network interface */ static int ipa_open(struct net_device *netdev) { … } /** ipa_stop() - Stops the modem network interface. */ static int ipa_stop(struct net_device *netdev) { … } /** ipa_start_xmit() - Transmit an skb * @skb: Socket buffer to be transmitted * @netdev: Network device * * Return: NETDEV_TX_OK if successful (or dropped), NETDEV_TX_BUSY otherwise * Normally NETDEV_TX_OK indicates the buffer was successfully transmitted. * If the buffer has an unexpected protocol or its size is out of range it * is quietly dropped, returning NETDEV_TX_OK. NETDEV_TX_BUSY indicates * the buffer cannot be sent at this time and should retried later. */ static netdev_tx_t ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev) { … } void ipa_modem_skb_rx(struct net_device *netdev, struct sk_buff *skb) { … } static const struct net_device_ops ipa_modem_ops = …; /** ipa_modem_netdev_setup() - netdev setup function for the modem */ static void ipa_modem_netdev_setup(struct net_device *netdev) { … } /** ipa_modem_suspend() - suspend callback * @netdev: Network device * * Suspend the modem's endpoints. */ void ipa_modem_suspend(struct net_device *netdev) { … } /** * ipa_modem_wake_queue_work() - enable modem netdev queue * @work: Work structure * * Re-enable transmit on the modem network device. This is called * in (power management) work queue context, scheduled when resuming * the modem. We can't enable the queue directly in ipa_modem_resume() * because transmits restart the instant the queue is awakened; but the * device power state won't be ACTIVE until *after* ipa_modem_resume() * returns. */ static void ipa_modem_wake_queue_work(struct work_struct *work) { … } /** ipa_modem_resume() - resume callback for runtime_pm * @dev: pointer to device * * Resume the modem's endpoints. */ void ipa_modem_resume(struct net_device *netdev) { … } int ipa_modem_start(struct ipa *ipa) { … } int ipa_modem_stop(struct ipa *ipa) { … } /* Treat a "clean" modem stop the same as a crash */ static void ipa_modem_crashed(struct ipa *ipa) { … } static int ipa_modem_notify(struct notifier_block *nb, unsigned long action, void *data) { … } int ipa_modem_config(struct ipa *ipa) { … } void ipa_modem_deconfig(struct ipa *ipa) { … }