1 /* 2 * Copyright (c) 2018,2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: qdf_net_if 22 * This file provides OS dependent network interface related APIs 23 */ 24 #include "qdf_net_if.h" 25 #include "qdf_types.h" 26 #include "qdf_module.h" 27 #include "qdf_util.h" 28 #include <linux/netdevice.h> 29 30 QDF_STATUS 31 qdf_net_if_create_dummy_if(struct qdf_net_if *nif) 32 { 33 int ret; 34 35 if (!nif) 36 return QDF_STATUS_E_INVAL; 37 38 ret = init_dummy_netdev((struct net_device *)nif); 39 40 return qdf_status_from_os_return(ret); 41 } 42 43 qdf_export_symbol(qdf_net_if_create_dummy_if); 44 45 /** 46 * qdf_net_if_get_devname() - Retrieve netdevice name 47 * @nif: Abstraction of netdevice 48 * 49 * Return: netdevice name 50 */ 51 char *qdf_net_if_get_devname(struct qdf_net_if *nif) 52 { 53 if (!nif) 54 return NULL; 55 56 return (((struct net_device *)nif)->name); 57 } 58 59 qdf_export_symbol(qdf_net_if_get_devname); 60 61 /** 62 * qdf_net_if_get_dev_by_name() - Find a network device by its name 63 * @nif_name: network device name 64 * 65 * This function retrieves the network device by its name 66 * 67 * Return: qdf network device 68 */ 69 struct qdf_net_if *qdf_net_if_get_dev_by_name(char *nif_name) 70 { 71 return __qdf_net_if_get_dev_by_name(nif_name); 72 } 73 74 qdf_export_symbol(qdf_net_if_get_dev_by_name); 75 76 /** 77 * qdf_net_if_release_dev() - Release reference to network device 78 * @nif: network device 79 * 80 * This function releases reference to the network device 81 * 82 * Return: QDF_STATUS_SUCCESS on success 83 */ 84 QDF_STATUS 85 qdf_net_if_release_dev(struct qdf_net_if *nif) 86 { 87 return __qdf_net_if_release_dev(nif); 88 } 89 90 qdf_export_symbol(qdf_net_if_release_dev); 91 92 /** 93 * qdf_net_update_net_device_dev_addr() - update net_device dev_addr 94 * @ndev: net_device 95 * @src_addr: source mac address 96 * @len: length 97 * 98 * kernel version 5.17 onwards made net_device->dev_addr as const unsigned char* 99 * so to update dev_addr, this function calls kernel api dev_addr_mod. 100 * 101 * Return: void 102 */ 103 void 104 qdf_net_update_net_device_dev_addr(struct net_device *ndev, 105 const void *src_addr, 106 size_t len) 107 { 108 __qdf_net_update_net_device_dev_addr(ndev, src_addr, len); 109 } 110 111 qdf_export_symbol(qdf_net_update_net_device_dev_addr); 112 113 void qdf_napi_enable(struct napi_struct *napi) 114 { 115 __qdf_napi_enable(napi); 116 } 117 118 qdf_export_symbol(qdf_napi_enable); 119 120 void qdf_napi_disable(struct napi_struct *napi) 121 { 122 __qdf_napi_disable(napi); 123 } 124 125 qdf_export_symbol(qdf_napi_disable); 126 127 void qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi, 128 int (*poll)(struct napi_struct *, int), int weight) 129 { 130 __qdf_netif_napi_add(netdev, napi, poll, weight); 131 } 132 133 qdf_export_symbol(qdf_netif_napi_add); 134 135 void qdf_netif_napi_del(struct napi_struct *napi) 136 { 137 __qdf_netif_napi_del(napi); 138 } 139 140 qdf_export_symbol(qdf_netif_napi_del); 141