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