Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame^] | 3 | * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | ************************************************************************** |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * nss_ipv6.c |
| 19 | * NSS IPv6 APIs |
| 20 | */ |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 21 | #include "nss_tx_rx_common.h" |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 22 | |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 23 | #define NSS_IPV6_TX_MSG_TIMEOUT 1000 /* 1 sec timeout for IPv4 messages */ |
| 24 | |
| 25 | /* |
| 26 | * Private data structure for ipv6 configure messages |
| 27 | */ |
| 28 | struct nss_ipv6_cfg_pvt { |
| 29 | struct semaphore sem; /* Semaphore structure */ |
| 30 | struct completion complete; /* completion structure */ |
| 31 | int current_value; /* valid entry */ |
| 32 | int response; /* Response from FW */ |
| 33 | }; |
| 34 | |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 35 | int nss_ipv6_conn_cfg __read_mostly = NSS_DEFAULT_NUM_CONN; |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 36 | int nss_ipv6_accel_mode_cfg __read_mostly = 1; |
| 37 | |
| 38 | static struct nss_ipv6_cfg_pvt i6_conn_cfgp; |
| 39 | static struct nss_ipv6_cfg_pvt i6_accel_mode_cfgp; |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 40 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 41 | /* |
Suruchi Agarwal | 611ecd0 | 2016-08-04 15:54:35 -0700 | [diff] [blame] | 42 | * Callback for conn_sync_many request message. |
| 43 | */ |
| 44 | nss_ipv6_msg_callback_t nss_ipv6_conn_sync_many_msg_cb = NULL; |
| 45 | |
| 46 | /* |
Gareth Williams | 958aa82 | 2015-02-04 19:36:39 +0000 | [diff] [blame] | 47 | * nss_ipv6_max_conn_count() |
| 48 | * Return the maximum number of IPv6 connections that the NSS acceleration engine supports. |
| 49 | */ |
| 50 | int nss_ipv6_max_conn_count(void) |
| 51 | { |
Tushar Mathur | 55ba130 | 2015-09-08 13:14:48 +0530 | [diff] [blame] | 52 | return nss_core_max_ipv6_conn_get(); |
Gareth Williams | 958aa82 | 2015-02-04 19:36:39 +0000 | [diff] [blame] | 53 | } |
| 54 | EXPORT_SYMBOL(nss_ipv6_max_conn_count); |
| 55 | |
| 56 | /* |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 57 | * nss_ipv6_driver_conn_sync_update() |
| 58 | * Update driver specific information from the messsage. |
| 59 | */ |
| 60 | static void nss_ipv6_driver_conn_sync_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync *nics) |
| 61 | { |
| 62 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * Update statistics maintained by NSS driver |
| 66 | */ |
| 67 | spin_lock_bh(&nss_top->stats_lock); |
| 68 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_RX_PKTS] += nics->flow_rx_packet_count + nics->return_rx_packet_count; |
| 69 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_RX_BYTES] += nics->flow_rx_byte_count + nics->return_rx_byte_count; |
| 70 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_TX_PKTS] += nics->flow_tx_packet_count + nics->return_tx_packet_count; |
| 71 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_TX_BYTES] += nics->flow_tx_byte_count + nics->return_tx_byte_count; |
Abhishek Rastogi | 55f3945 | 2014-05-08 19:23:29 +0530 | [diff] [blame] | 72 | spin_unlock_bh(&nss_top->stats_lock); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /* |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 76 | * nss_ipv6_driver_conn_sync_many_update() |
| 77 | * Update driver specific information from the conn_sync_many messsage. |
| 78 | */ |
| 79 | static void nss_ipv6_driver_conn_sync_many_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync_many_msg *nicsm) |
| 80 | { |
| 81 | uint32_t i; |
| 82 | |
| 83 | /* |
| 84 | * Sanity check for the stats count |
| 85 | */ |
| 86 | if (nicsm->count * sizeof(struct nss_ipv6_conn_sync) >= nicsm->size) { |
| 87 | nss_warning("%p: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | for (i = 0; i < nicsm->count; i++) { |
| 92 | nss_ipv6_driver_conn_sync_update(nss_ctx, &nicsm->conn_sync[i]); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /* |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 97 | * nss_ipv6_driver_node_sync_update) |
| 98 | * Update driver specific information from the messsage. |
| 99 | */ |
| 100 | static void nss_ipv6_driver_node_sync_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_node_sync *nins) |
| 101 | { |
| 102 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
| 103 | uint32_t i; |
| 104 | |
| 105 | /* |
| 106 | * Update statistics maintained by NSS driver |
| 107 | */ |
| 108 | spin_lock_bh(&nss_top->stats_lock); |
| 109 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nins->node_stats.rx_packets; |
| 110 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nins->node_stats.rx_bytes; |
| 111 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_DROPPED] += nins->node_stats.rx_dropped; |
| 112 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nins->node_stats.tx_packets; |
| 113 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nins->node_stats.tx_bytes; |
| 114 | |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 115 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_REQUESTS] += nins->ipv6_connection_create_requests; |
| 116 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_COLLISIONS] += nins->ipv6_connection_create_collisions; |
| 117 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv6_connection_create_invalid_interface; |
| 118 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_DESTROY_REQUESTS] += nins->ipv6_connection_destroy_requests; |
| 119 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_DESTROY_MISSES] += nins->ipv6_connection_destroy_misses; |
| 120 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_HASH_HITS] += nins->ipv6_connection_hash_hits; |
| 121 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_HASH_REORDERS] += nins->ipv6_connection_hash_reorders; |
| 122 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_FLUSHES] += nins->ipv6_connection_flushes; |
| 123 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_EVICTIONS] += nins->ipv6_connection_evictions; |
Selin Dag | 5d68caa | 2015-05-12 13:23:33 -0700 | [diff] [blame] | 124 | nss_top->stats_ipv6[NSS_STATS_IPV6_FRAGMENTATIONS] += nins->ipv6_fragmentations; |
| 125 | nss_top->stats_ipv6[NSS_STATS_IPV6_FRAG_FAILS] += nins->ipv6_frag_fails; |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 126 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_CREATE_REQUESTS] += nins->ipv6_mc_connection_create_requests; |
| 127 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_UPDATE_REQUESTS] += nins->ipv6_mc_connection_update_requests; |
| 128 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv6_mc_connection_create_invalid_interface; |
| 129 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_DESTROY_REQUESTS] += nins->ipv6_mc_connection_destroy_requests; |
| 130 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_DESTROY_MISSES] += nins->ipv6_mc_connection_destroy_misses; |
| 131 | nss_top->stats_ipv6[NSS_STATS_IPV6_MC_CONNECTION_FLUSHES] += nins->ipv6_mc_connection_flushes; |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 132 | |
| 133 | for (i = 0; i < NSS_EXCEPTION_EVENT_IPV6_MAX; i++) { |
| 134 | nss_top->stats_if_exception_ipv6[i] += nins->exception_events[i]; |
| 135 | } |
| 136 | spin_unlock_bh(&nss_top->stats_lock); |
| 137 | } |
| 138 | |
| 139 | /* |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 140 | * nss_ipv6_rx_msg_handler() |
| 141 | * Handle NSS -> HLOS messages for IPv6 bridge/route |
| 142 | */ |
| 143 | static void nss_ipv6_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) |
| 144 | { |
| 145 | struct nss_ipv6_msg *nim = (struct nss_ipv6_msg *)ncm; |
| 146 | nss_ipv6_msg_callback_t cb; |
| 147 | |
| 148 | BUG_ON(ncm->interface != NSS_IPV6_RX_INTERFACE); |
| 149 | |
| 150 | /* |
| 151 | * Is this a valid request/response packet? |
| 152 | */ |
Murat Sezgin | 5c8c736 | 2014-09-02 17:58:21 -0700 | [diff] [blame] | 153 | if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 154 | nss_warning("%p: received invalid message %d for IPv6 interface", nss_ctx, nim->cm.type); |
| 155 | return; |
| 156 | } |
| 157 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 158 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipv6_msg)) { |
| 159 | nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 160 | return; |
| 161 | } |
| 162 | |
| 163 | /* |
Suruchi Agarwal | e3940e7 | 2016-07-06 15:56:51 -0700 | [diff] [blame] | 164 | * Trace messages. |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 165 | */ |
Suruchi Agarwal | e3940e7 | 2016-07-06 15:56:51 -0700 | [diff] [blame] | 166 | nss_ipv6_log_rx_msg(nim); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 167 | |
| 168 | /* |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 169 | * Handle deprecated messages. Eventually these messages should be removed. |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 170 | */ |
| 171 | switch (nim->cm.type) { |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 172 | case NSS_IPV6_RX_NODE_STATS_SYNC_MSG: |
| 173 | /* |
| 174 | * Update driver statistics on node sync. |
| 175 | */ |
| 176 | nss_ipv6_driver_node_sync_update(nss_ctx, &nim->msg.node_stats); |
| 177 | break; |
| 178 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 179 | case NSS_IPV6_RX_CONN_STATS_SYNC_MSG: |
| 180 | /* |
| 181 | * Update driver statistics on connection sync. |
| 182 | */ |
| 183 | nss_ipv6_driver_conn_sync_update(nss_ctx, &nim->msg.conn_stats); |
Sakthi Vignesh Radhakrishnan | 515f8c2 | 2014-06-21 15:04:19 -0700 | [diff] [blame] | 184 | break; |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 185 | |
| 186 | case NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG: |
| 187 | /* |
| 188 | * Update driver statistics on connection sync many. |
| 189 | */ |
| 190 | nss_ipv6_driver_conn_sync_many_update(nss_ctx, &nim->msg.conn_stats_many); |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame^] | 191 | ncm->cb = (nss_ptr_t)nss_ipv6_conn_sync_many_msg_cb; |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 192 | break; |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 193 | } |
Abhishek Rastogi | 55f3945 | 2014-05-08 19:23:29 +0530 | [diff] [blame] | 194 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 195 | /* |
| 196 | * Update the callback and app_data for NOTIFY messages, IPv6 sends all notify messages |
| 197 | * to the same callback/app_data. |
| 198 | */ |
| 199 | if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY) { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame^] | 200 | ncm->cb = (nss_ptr_t)nss_ctx->nss_top->ipv6_callback; |
| 201 | ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->ipv6_ctx; |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | /* |
| 205 | * Do we have a callback? |
| 206 | */ |
| 207 | if (!ncm->cb) { |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | /* |
| 212 | * Callback |
| 213 | */ |
| 214 | cb = (nss_ipv6_msg_callback_t)ncm->cb; |
| 215 | cb((void *)ncm->app_data, nim); |
| 216 | } |
| 217 | |
| 218 | /* |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 219 | * nss_ipv6_tx_with_size() |
| 220 | * Transmit an ipv6 message to the FW with a specified size. |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 221 | */ |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 222 | nss_tx_status_t nss_ipv6_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim, uint32_t size) |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 223 | { |
| 224 | struct nss_ipv6_msg *nim2; |
| 225 | struct nss_cmn_msg *ncm = &nim->cm; |
| 226 | struct sk_buff *nbuf; |
| 227 | int32_t status; |
| 228 | |
| 229 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 230 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
| 231 | nss_warning("%p: ipv6 msg dropped as core not ready", nss_ctx); |
| 232 | return NSS_TX_FAILURE_NOT_READY; |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | * Sanity check the message |
| 237 | */ |
| 238 | if (ncm->interface != NSS_IPV6_RX_INTERFACE) { |
| 239 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 240 | return NSS_TX_FAILURE; |
| 241 | } |
| 242 | |
Murat Sezgin | 5c8c736 | 2014-09-02 17:58:21 -0700 | [diff] [blame] | 243 | if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 244 | nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); |
| 245 | return NSS_TX_FAILURE; |
| 246 | } |
| 247 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 248 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipv6_msg)) { |
| 249 | nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 250 | return NSS_TX_FAILURE; |
| 251 | } |
| 252 | |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 253 | if(size > PAGE_SIZE) { |
| 254 | nss_warning("%p: tx request size too large: %u", nss_ctx, size); |
| 255 | return NSS_TX_FAILURE; |
| 256 | } |
| 257 | |
| 258 | nbuf = dev_alloc_skb(size); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 259 | if (unlikely(!nbuf)) { |
Sundarajan Srinivasan | 62fee7e | 2015-01-22 11:13:10 -0800 | [diff] [blame] | 260 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 261 | nss_warning("%p: msg dropped as command allocation failed", nss_ctx); |
| 262 | return NSS_TX_FAILURE; |
| 263 | } |
| 264 | |
| 265 | /* |
| 266 | * Copy the message to our skb. |
| 267 | */ |
Suruchi Agarwal | ea2e523 | 2016-09-14 10:32:08 -0700 | [diff] [blame] | 268 | nim2 = (struct nss_ipv6_msg *)skb_put(nbuf, size); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 269 | memcpy(nim2, nim, sizeof(struct nss_ipv6_msg)); |
| 270 | |
Suruchi Agarwal | e3940e7 | 2016-07-06 15:56:51 -0700 | [diff] [blame] | 271 | /* |
| 272 | * Trace messages. |
| 273 | */ |
| 274 | nss_ipv6_log_tx_msg(nim); |
| 275 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 276 | status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0); |
| 277 | if (status != NSS_CORE_STATUS_SUCCESS) { |
Pamidipati, Vijay | b6e3884 | 2014-09-16 10:26:05 +0530 | [diff] [blame] | 278 | dev_kfree_skb_any(nbuf); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 279 | nss_warning("%p: Unable to enqueue 'Destroy IPv6' rule\n", nss_ctx); |
| 280 | return NSS_TX_FAILURE; |
| 281 | } |
| 282 | |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 283 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 284 | |
| 285 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]); |
| 286 | return NSS_TX_SUCCESS; |
| 287 | } |
| 288 | |
| 289 | /* |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 290 | * nss_ipv6_tx() |
Suruchi Agarwal | 611ecd0 | 2016-08-04 15:54:35 -0700 | [diff] [blame] | 291 | * Transmit an ipv6 message to the FW. |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 292 | */ |
| 293 | nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim) |
| 294 | { |
| 295 | return nss_ipv6_tx_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE); |
| 296 | } |
| 297 | |
| 298 | /* |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 299 | ********************************** |
| 300 | Register/Unregister/Miscellaneous APIs |
| 301 | ********************************** |
| 302 | */ |
| 303 | |
| 304 | /* |
| 305 | * nss_ipv6_notify_register() |
| 306 | * Register to received IPv6 events. |
| 307 | * |
| 308 | * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? |
| 309 | */ |
| 310 | struct nss_ctx_instance *nss_ipv6_notify_register(nss_ipv6_msg_callback_t cb, void *app_data) |
| 311 | { |
| 312 | /* |
| 313 | * TODO: We need to have a new array in support of the new API |
| 314 | * TODO: If we use a per-context array, we would move the array into nss_ctx based. |
| 315 | */ |
| 316 | nss_top_main.ipv6_callback = cb; |
| 317 | nss_top_main.ipv6_ctx = app_data; |
| 318 | return &nss_top_main.nss[nss_top_main.ipv6_handler_id]; |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * nss_ipv6_notify_unregister() |
| 323 | * Unregister to received IPv6 events. |
| 324 | * |
| 325 | * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? |
| 326 | */ |
| 327 | void nss_ipv6_notify_unregister(void) |
| 328 | { |
| 329 | nss_top_main.ipv6_callback = NULL; |
| 330 | } |
| 331 | |
| 332 | /* |
Suruchi Agarwal | 611ecd0 | 2016-08-04 15:54:35 -0700 | [diff] [blame] | 333 | * nss_ipv6_conn_sync_many_notify_register() |
| 334 | * Register to receive IPv6 conn_sync_many message response. |
| 335 | */ |
| 336 | void nss_ipv6_conn_sync_many_notify_register(nss_ipv6_msg_callback_t cb) |
| 337 | { |
| 338 | nss_ipv6_conn_sync_many_msg_cb = cb; |
| 339 | } |
| 340 | |
| 341 | /* |
| 342 | * nss_ipv6_conn_sync_many_notify_unregister() |
| 343 | * Unregister to receive IPv6 conn_sync_many message response. |
| 344 | */ |
| 345 | void nss_ipv6_conn_sync_many_notify_unregister(void) |
| 346 | { |
| 347 | nss_ipv6_conn_sync_many_msg_cb = NULL; |
| 348 | } |
| 349 | |
| 350 | /* |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 351 | * nss_ipv6_get_mgr() |
| 352 | * |
| 353 | * TODO: This only suppports a single ipv6, do we ever want to support more? |
| 354 | */ |
| 355 | struct nss_ctx_instance *nss_ipv6_get_mgr(void) |
| 356 | { |
| 357 | return (void *)&nss_top_main.nss[nss_top_main.ipv6_handler_id]; |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | * nss_ipv6_register_handler() |
| 362 | * Register our handler to receive messages for this interface |
| 363 | */ |
| 364 | void nss_ipv6_register_handler() |
| 365 | { |
| 366 | if (nss_core_register_handler(NSS_IPV6_RX_INTERFACE, nss_ipv6_rx_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { |
| 367 | nss_warning("IPv6 handler failed to register"); |
| 368 | } |
| 369 | } |
| 370 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 371 | /* |
Tushar Mathur | a3c1893 | 2015-08-24 20:27:21 +0530 | [diff] [blame] | 372 | * nss_ipv6_conn_cfg_process() |
| 373 | * Process request to configure number of ipv6 connections |
| 374 | */ |
| 375 | static int nss_ipv6_conn_cfg_process(struct nss_ctx_instance *nss_ctx, int conn, |
| 376 | void (*cfg_cb)(void *app_data, struct nss_ipv6_msg *nim)) |
| 377 | { |
| 378 | struct nss_ipv6_msg nim; |
| 379 | struct nss_ipv6_rule_conn_cfg_msg *nirccm; |
| 380 | nss_tx_status_t nss_tx_status; |
| 381 | uint32_t sum_of_conn; |
| 382 | |
| 383 | /* |
| 384 | * Specifications for input |
| 385 | * 1) The input should be power of 2. |
| 386 | * 2) Input for ipv4 and ipv6 sum togther should not exceed 8k |
| 387 | * 3) Min. value should be at leat 256 connections. This is the |
| 388 | * minimum connections we will support for each of them. |
| 389 | */ |
| 390 | sum_of_conn = nss_ipv4_conn_cfg + conn; |
| 391 | if ((conn & NSS_NUM_CONN_QUANTA_MASK) || |
| 392 | (sum_of_conn > NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6) || |
| 393 | (conn < NSS_MIN_NUM_CONN)) { |
| 394 | nss_warning("%p: input supported connections (%d) does not adhere\ |
| 395 | specifications\n1) not power of 2,\n2) is less than \ |
| 396 | min val: %d, OR\n IPv4/6 total exceeds %d\n", |
| 397 | nss_ctx, |
| 398 | conn, |
| 399 | NSS_MIN_NUM_CONN, |
| 400 | NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6); |
| 401 | return -EINVAL; |
| 402 | } |
| 403 | |
| 404 | nss_info("%p: IPv6 supported connections: %d\n", nss_ctx, conn); |
| 405 | |
| 406 | memset(&nim, 0, sizeof(struct nss_ipv6_msg)); |
| 407 | nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_CONN_CFG_RULE_MSG, |
| 408 | sizeof(struct nss_ipv6_rule_conn_cfg_msg), cfg_cb, NULL); |
| 409 | |
| 410 | nirccm = &nim.msg.rule_conn_cfg; |
| 411 | nirccm->num_conn = htonl(conn); |
| 412 | nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); |
| 413 | |
| 414 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 415 | nss_warning("%p: nss_tx error setting IPv6 Connections: %d\n", |
| 416 | nss_ctx, |
| 417 | conn); |
| 418 | return -EIO; |
| 419 | } |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | /* |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 425 | * nss_ipv6_conn_cfg_callback() |
| 426 | * call back function for the ipv6 connection configuration handler |
| 427 | */ |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 428 | static void nss_ipv6_conn_cfg_callback(void *app_data, struct nss_ipv6_msg *nim) |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 429 | { |
| 430 | if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 431 | /* |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 432 | * Error, hence we are not updating the nss_ipv6_conn_cfg |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 433 | * Restore the current_value to its previous state |
| 434 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 435 | i6_conn_cfgp.response = NSS_FAILURE; |
| 436 | complete(&i6_conn_cfgp.complete); |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 437 | return; |
| 438 | } |
| 439 | |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 440 | /* |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 441 | * Sucess at NSS FW, hence updating nss_ipv6_conn_cfg, with the valid value |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 442 | * saved at the sysctl handler. |
| 443 | */ |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 444 | nss_info("IPv6 connection configuration success: %d\n", nim->cm.error); |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 445 | i6_conn_cfgp.response = NSS_SUCCESS; |
| 446 | complete(&i6_conn_cfgp.complete); |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | |
| 450 | /* |
| 451 | * nss_ipv6_conn_cfg_handler() |
| 452 | * Sets the number of connections for IPv6 |
| 453 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 454 | static int nss_ipv6_conn_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 455 | { |
| 456 | struct nss_top_instance *nss_top = &nss_top_main; |
| 457 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 458 | int ret = NSS_FAILURE; |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 459 | |
| 460 | /* |
| 461 | * Acquiring semaphore |
| 462 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 463 | down(&i6_conn_cfgp.sem); |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 464 | |
| 465 | /* |
| 466 | * Take a snapshot of the current value |
| 467 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 468 | i6_conn_cfgp.current_value = nss_ipv6_conn_cfg; |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 469 | |
| 470 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 471 | if (ret || (!write)) { |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 472 | up(&i6_conn_cfgp.sem); |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 473 | return ret; |
| 474 | } |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 475 | |
| 476 | /* |
Tushar Mathur | a3c1893 | 2015-08-24 20:27:21 +0530 | [diff] [blame] | 477 | * Process request to change number of IPv6 connections |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 478 | */ |
Tushar Mathur | a3c1893 | 2015-08-24 20:27:21 +0530 | [diff] [blame] | 479 | ret = nss_ipv6_conn_cfg_process(nss_ctx, nss_ipv6_conn_cfg, nss_ipv6_conn_cfg_callback); |
| 480 | if (ret != 0) { |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 481 | goto failure; |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 482 | } |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 483 | |
| 484 | /* |
| 485 | * Blocking call, wait till we get ACK for this msg. |
| 486 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 487 | ret = wait_for_completion_timeout(&i6_conn_cfgp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 488 | if (ret == 0) { |
| 489 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 490 | goto failure; |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /* |
| 494 | * ACK/NACK received from NSS FW |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 495 | * If ACK: Callback function will update nss_ipv6_conn_cfg with |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 496 | * i6_conn_cfgp.num_conn_valid, which holds the user input |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 497 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 498 | if (NSS_FAILURE == i6_conn_cfgp.response) { |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 499 | goto failure; |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 502 | up(&i6_conn_cfgp.sem); |
Thomas Wu | 651b390 | 2015-05-12 11:21:09 -0700 | [diff] [blame] | 503 | return 0; |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 504 | |
| 505 | failure: |
| 506 | /* |
| 507 | * Restore the current_value to its previous state |
| 508 | */ |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 509 | nss_ipv6_conn_cfg = i6_conn_cfgp.current_value; |
| 510 | up(&i6_conn_cfgp.sem); |
Thomas Wu | 651b390 | 2015-05-12 11:21:09 -0700 | [diff] [blame] | 511 | return -EINVAL; |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Tushar Mathur | a3c1893 | 2015-08-24 20:27:21 +0530 | [diff] [blame] | 514 | /* |
| 515 | * nss_ipv6_update_conn_count_cb() |
| 516 | * call back function for the ipv6 connection count update handler |
| 517 | */ |
| 518 | static void nss_ipv6_update_conn_count_cb(void *app_data, struct nss_ipv6_msg *nim) |
| 519 | { |
| 520 | if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 521 | nss_warning("IPv6 connection count update failed with error: %d\n", nim->cm.error); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | nss_warning("IPv6 connection count update success: %d\n", nim->cm.error); |
| 526 | } |
| 527 | |
| 528 | /* |
| 529 | * nss_ipv6_update_conn_count() |
| 530 | * Sets the maximum number of connections for IPv6 |
| 531 | */ |
| 532 | int nss_ipv6_update_conn_count(int ipv6_num_conn) |
| 533 | { |
| 534 | struct nss_top_instance *nss_top = &nss_top_main; |
| 535 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 536 | int saved_nss_ipv6_conn_cfg = nss_ipv6_conn_cfg; |
| 537 | int ret = 0; |
| 538 | |
| 539 | nss_ipv6_conn_cfg = ipv6_num_conn; |
| 540 | |
| 541 | /* |
| 542 | * Process request to change number of IPv6 connections |
| 543 | */ |
| 544 | ret = nss_ipv6_conn_cfg_process(nss_ctx, nss_ipv6_conn_cfg, nss_ipv6_update_conn_count_cb); |
| 545 | if (ret != 0) { |
| 546 | goto failure; |
| 547 | } |
| 548 | |
| 549 | return 0; |
| 550 | |
| 551 | failure: |
| 552 | nss_ipv6_conn_cfg = saved_nss_ipv6_conn_cfg; |
| 553 | return -EINVAL; |
| 554 | } |
| 555 | |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 556 | /* |
| 557 | * nss_ipv6_accel_mode_cfg_callback() |
| 558 | * call back function for the ipv6 acceleration mode configurate handler |
| 559 | */ |
| 560 | static void nss_ipv6_accel_mode_cfg_callback(void *app_data, struct nss_ipv6_msg *nim) |
| 561 | { |
| 562 | if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 563 | nss_warning("IPv6 acceleration mode configuration failed with error: %d\n", nim->cm.error); |
| 564 | i6_accel_mode_cfgp.response = NSS_FAILURE; |
| 565 | complete(&i6_accel_mode_cfgp.complete); |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | nss_info("IPv6 acceleration mode configuration success\n"); |
| 570 | i6_accel_mode_cfgp.response = NSS_SUCCESS; |
| 571 | complete(&i6_accel_mode_cfgp.complete); |
| 572 | } |
| 573 | |
| 574 | /* |
| 575 | * nss_ipv6_accel_mode_cfg_handler() |
| 576 | * Configure acceleration mode for IPv6 |
| 577 | */ |
| 578 | static int nss_ipv6_accel_mode_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 579 | { |
| 580 | struct nss_top_instance *nss_top = &nss_top_main; |
| 581 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 582 | struct nss_ipv6_msg nim; |
| 583 | struct nss_ipv6_accel_mode_cfg_msg *nipcm; |
| 584 | nss_tx_status_t nss_tx_status; |
| 585 | int ret = NSS_FAILURE; |
| 586 | |
| 587 | /* |
| 588 | * Acquiring semaphore |
| 589 | */ |
| 590 | down(&i6_accel_mode_cfgp.sem); |
| 591 | |
| 592 | /* |
| 593 | * Take snap shot of current value |
| 594 | */ |
| 595 | i6_accel_mode_cfgp.current_value = nss_ipv6_accel_mode_cfg; |
| 596 | |
| 597 | /* |
| 598 | * Write the variable with user input |
| 599 | */ |
| 600 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 601 | if (ret || (!write)) { |
| 602 | up(&i6_accel_mode_cfgp.sem); |
| 603 | return ret; |
| 604 | } |
| 605 | |
| 606 | memset(&nim, 0, sizeof(struct nss_ipv6_msg)); |
| 607 | nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_ACCEL_MODE_CFG_MSG, |
| 608 | sizeof(struct nss_ipv6_accel_mode_cfg_msg), nss_ipv6_accel_mode_cfg_callback, NULL); |
| 609 | |
| 610 | nipcm = &nim.msg.accel_mode_cfg; |
| 611 | nipcm->mode = htonl(nss_ipv6_accel_mode_cfg); |
| 612 | nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); |
| 613 | |
| 614 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 615 | nss_warning("%p: Send acceleration mode message failed\n", nss_ctx); |
| 616 | goto fail; |
| 617 | } |
| 618 | |
| 619 | /* |
| 620 | * Blocking call, wait till we get ACK for this msg. |
| 621 | */ |
| 622 | ret = wait_for_completion_timeout(&i6_accel_mode_cfgp.complete, msecs_to_jiffies(NSS_IPV6_TX_MSG_TIMEOUT)); |
| 623 | if (ret == 0) { |
| 624 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 625 | goto fail; |
| 626 | } |
| 627 | |
| 628 | if (NSS_FAILURE == i6_accel_mode_cfgp.response) { |
| 629 | nss_warning("%p: accel mode configure failed\n", nss_ctx); |
| 630 | goto fail; |
| 631 | } |
| 632 | |
| 633 | up(&i6_accel_mode_cfgp.sem); |
| 634 | return 0; |
| 635 | |
| 636 | fail: |
| 637 | nss_ipv6_accel_mode_cfg = i6_accel_mode_cfgp.current_value; |
| 638 | up(&i6_accel_mode_cfgp.sem); |
| 639 | return -EIO; |
| 640 | } |
| 641 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 642 | static struct ctl_table nss_ipv6_table[] = { |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 643 | { |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 644 | .procname = "ipv6_conn", |
| 645 | .data = &nss_ipv6_conn_cfg, |
| 646 | .maxlen = sizeof(int), |
| 647 | .mode = 0644, |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 648 | .proc_handler = &nss_ipv6_conn_cfg_handler, |
| 649 | }, |
| 650 | { |
| 651 | .procname = "ipv6_accel_mode", |
| 652 | .data = &nss_ipv6_accel_mode_cfg, |
| 653 | .maxlen = sizeof(int), |
| 654 | .mode = 0644, |
| 655 | .proc_handler = &nss_ipv6_accel_mode_cfg_handler, |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 656 | }, |
| 657 | { } |
| 658 | }; |
| 659 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 660 | static struct ctl_table nss_ipv6_dir[] = { |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 661 | { |
Vijay Dewangan | 4861f4e | 2014-10-14 16:56:35 -0700 | [diff] [blame] | 662 | .procname = "ipv6cfg", |
| 663 | .mode = 0555, |
| 664 | .child = nss_ipv6_table, |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 665 | }, |
| 666 | { } |
| 667 | }; |
| 668 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 669 | static struct ctl_table nss_ipv6_root_dir[] = { |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 670 | { |
| 671 | .procname = "nss", |
| 672 | .mode = 0555, |
| 673 | .child = nss_ipv6_dir, |
| 674 | }, |
| 675 | { } |
| 676 | }; |
| 677 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 678 | static struct ctl_table nss_ipv6_root[] = { |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 679 | { |
| 680 | .procname = "dev", |
| 681 | .mode = 0555, |
| 682 | .child = nss_ipv6_root_dir, |
| 683 | }, |
| 684 | { } |
| 685 | }; |
| 686 | |
| 687 | static struct ctl_table_header *nss_ipv6_header; |
| 688 | |
| 689 | /* |
| 690 | * nss_ipv6_register_sysctl() |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 691 | * Register sysctl specific to ipv6 |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 692 | */ |
| 693 | void nss_ipv6_register_sysctl(void) |
| 694 | { |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 695 | sema_init(&i6_conn_cfgp.sem, 1); |
| 696 | init_completion(&i6_conn_cfgp.complete); |
| 697 | |
| 698 | sema_init(&i6_accel_mode_cfgp.sem, 1); |
| 699 | init_completion(&i6_accel_mode_cfgp.complete); |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 700 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 701 | /* |
| 702 | * Register sysctl table. |
| 703 | */ |
| 704 | nss_ipv6_header = register_sysctl_table(nss_ipv6_root); |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | * nss_ipv6_unregister_sysctl() |
Kiran Kumar C.S.K | fadf92d | 2015-06-26 12:48:33 +0530 | [diff] [blame] | 709 | * Unregister sysctl specific to ipv6 |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 710 | */ |
| 711 | void nss_ipv6_unregister_sysctl(void) |
| 712 | { |
| 713 | /* |
| 714 | * Unregister sysctl table. |
| 715 | */ |
| 716 | if (nss_ipv6_header) { |
| 717 | unregister_sysctl_table(nss_ipv6_header); |
| 718 | } |
| 719 | } |
| 720 | |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 721 | /* |
| 722 | * nss_ipv6_msg_init() |
Stephen Wang | 0a2756a | 2016-08-04 15:52:47 -0700 | [diff] [blame] | 723 | * Initialize IPv6 message. |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 724 | */ |
| 725 | void nss_ipv6_msg_init(struct nss_ipv6_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, |
Sundarajan Srinivasan | 30a53d4 | 2015-01-30 10:52:08 -0800 | [diff] [blame] | 726 | nss_ipv6_msg_callback_t cb, void *app_data) |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 727 | { |
| 728 | nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); |
| 729 | } |
| 730 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 731 | EXPORT_SYMBOL(nss_ipv6_tx); |
Stephen Wang | 709f9b5 | 2015-07-07 14:48:35 -0700 | [diff] [blame] | 732 | EXPORT_SYMBOL(nss_ipv6_tx_with_size); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 733 | EXPORT_SYMBOL(nss_ipv6_notify_register); |
| 734 | EXPORT_SYMBOL(nss_ipv6_notify_unregister); |
Suruchi Agarwal | 611ecd0 | 2016-08-04 15:54:35 -0700 | [diff] [blame] | 735 | EXPORT_SYMBOL(nss_ipv6_conn_sync_many_notify_register); |
| 736 | EXPORT_SYMBOL(nss_ipv6_conn_sync_many_notify_unregister); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 737 | EXPORT_SYMBOL(nss_ipv6_get_mgr); |
| 738 | EXPORT_SYMBOL(nss_ipv6_register_handler); |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 739 | EXPORT_SYMBOL(nss_ipv6_register_sysctl); |
| 740 | EXPORT_SYMBOL(nss_ipv6_unregister_sysctl); |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 741 | EXPORT_SYMBOL(nss_ipv6_msg_init); |
Tushar Mathur | a3c1893 | 2015-08-24 20:27:21 +0530 | [diff] [blame] | 742 | EXPORT_SYMBOL(nss_ipv6_update_conn_count); |