Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
| 3 | * Copyright (c) 2014, The Linux Foundation. All rights reserved. |
| 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 | */ |
| 21 | #include <linux/ppp_channel.h> |
| 22 | #include "nss_tx_rx_common.h" |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 23 | |
| 24 | extern void nss_rx_metadata_ipv6_rule_establish(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_rule_establish *nire); |
Sakthi Vignesh Radhakrishnan | 515f8c2 | 2014-06-21 15:04:19 -0700 | [diff] [blame] | 25 | extern void nss_rx_metadata_ipv6_create_response(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 26 | extern void nss_rx_ipv6_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync *nirs); |
| 27 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame^] | 28 | int nss_ipv6_conn_cfg __read_mostly = 4096; |
| 29 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 30 | /* |
| 31 | * nss_ipv6_driver_conn_sync_update() |
| 32 | * Update driver specific information from the messsage. |
| 33 | */ |
| 34 | static void nss_ipv6_driver_conn_sync_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync *nics) |
| 35 | { |
| 36 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
| 37 | struct net_device *pppoe_dev = NULL; |
| 38 | |
| 39 | /* |
| 40 | * Update statistics maintained by NSS driver |
| 41 | */ |
| 42 | spin_lock_bh(&nss_top->stats_lock); |
| 43 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_RX_PKTS] += nics->flow_rx_packet_count + nics->return_rx_packet_count; |
| 44 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_RX_BYTES] += nics->flow_rx_byte_count + nics->return_rx_byte_count; |
| 45 | nss_top->stats_ipv6[NSS_STATS_IPV6_ACCELERATED_TX_PKTS] += nics->flow_tx_packet_count + nics->return_tx_packet_count; |
| 46 | 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] | 47 | spin_unlock_bh(&nss_top->stats_lock); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * Update the PPPoE interface stats, if there is any PPPoE session on the interfaces. |
| 51 | */ |
| 52 | if (nics->flow_pppoe_session_id) { |
| 53 | pppoe_dev = ppp_session_to_netdev(nics->flow_pppoe_session_id, (uint8_t *)nics->flow_pppoe_remote_mac); |
| 54 | if (pppoe_dev) { |
| 55 | ppp_update_stats(pppoe_dev, nics->flow_rx_packet_count, nics->flow_rx_byte_count, |
| 56 | nics->flow_tx_packet_count, nics->flow_tx_byte_count); |
| 57 | dev_put(pppoe_dev); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | if (nics->return_pppoe_session_id) { |
| 62 | pppoe_dev = ppp_session_to_netdev(nics->return_pppoe_session_id, (uint8_t *)nics->return_pppoe_remote_mac); |
| 63 | if (pppoe_dev) { |
| 64 | ppp_update_stats(pppoe_dev, nics->return_rx_packet_count, nics->return_rx_byte_count, |
| 65 | nics->return_tx_packet_count, nics->return_tx_byte_count); |
| 66 | dev_put(pppoe_dev); |
| 67 | } |
| 68 | } |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 72 | * nss_ipv6_driver_node_sync_update) |
| 73 | * Update driver specific information from the messsage. |
| 74 | */ |
| 75 | static void nss_ipv6_driver_node_sync_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_node_sync *nins) |
| 76 | { |
| 77 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
| 78 | uint32_t i; |
| 79 | |
| 80 | /* |
| 81 | * Update statistics maintained by NSS driver |
| 82 | */ |
| 83 | spin_lock_bh(&nss_top->stats_lock); |
| 84 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nins->node_stats.rx_packets; |
| 85 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nins->node_stats.rx_bytes; |
| 86 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_DROPPED] += nins->node_stats.rx_dropped; |
| 87 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nins->node_stats.tx_packets; |
| 88 | nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nins->node_stats.tx_bytes; |
| 89 | |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 90 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_REQUESTS] += nins->ipv6_connection_create_requests; |
| 91 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_COLLISIONS] += nins->ipv6_connection_create_collisions; |
| 92 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv6_connection_create_invalid_interface; |
| 93 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_DESTROY_REQUESTS] += nins->ipv6_connection_destroy_requests; |
| 94 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_DESTROY_MISSES] += nins->ipv6_connection_destroy_misses; |
| 95 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_HASH_HITS] += nins->ipv6_connection_hash_hits; |
| 96 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_HASH_REORDERS] += nins->ipv6_connection_hash_reorders; |
| 97 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_FLUSHES] += nins->ipv6_connection_flushes; |
| 98 | nss_top->stats_ipv6[NSS_STATS_IPV6_CONNECTION_EVICTIONS] += nins->ipv6_connection_evictions; |
| 99 | |
| 100 | for (i = 0; i < NSS_EXCEPTION_EVENT_IPV6_MAX; i++) { |
| 101 | nss_top->stats_if_exception_ipv6[i] += nins->exception_events[i]; |
| 102 | } |
| 103 | spin_unlock_bh(&nss_top->stats_lock); |
| 104 | } |
| 105 | |
| 106 | /* |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 107 | * nss_ipv6_rx_msg_handler() |
| 108 | * Handle NSS -> HLOS messages for IPv6 bridge/route |
| 109 | */ |
| 110 | static void nss_ipv6_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) |
| 111 | { |
| 112 | struct nss_ipv6_msg *nim = (struct nss_ipv6_msg *)ncm; |
| 113 | nss_ipv6_msg_callback_t cb; |
| 114 | |
| 115 | BUG_ON(ncm->interface != NSS_IPV6_RX_INTERFACE); |
| 116 | |
| 117 | /* |
| 118 | * Is this a valid request/response packet? |
| 119 | */ |
Murat Sezgin | 5c8c736 | 2014-09-02 17:58:21 -0700 | [diff] [blame] | 120 | if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 121 | nss_warning("%p: received invalid message %d for IPv6 interface", nss_ctx, nim->cm.type); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | if (ncm->len > sizeof(struct nss_ipv6_msg)) { |
| 126 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | * Log failures |
| 132 | */ |
| 133 | nss_core_log_msg_failures(nss_ctx, ncm); |
| 134 | |
| 135 | /* |
| 136 | * Handle deprecated messages. Eventually these messages should be removed. |
| 137 | */ |
| 138 | switch (nim->cm.type) { |
| 139 | case NSS_IPV6_RX_ESTABLISH_RULE_MSG: |
| 140 | nss_rx_metadata_ipv6_rule_establish(nss_ctx, &nim->msg.rule_establish); |
| 141 | break; |
| 142 | |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 143 | case NSS_IPV6_RX_NODE_STATS_SYNC_MSG: |
| 144 | /* |
| 145 | * Update driver statistics on node sync. |
| 146 | */ |
| 147 | nss_ipv6_driver_node_sync_update(nss_ctx, &nim->msg.node_stats); |
| 148 | break; |
| 149 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 150 | case NSS_IPV6_RX_CONN_STATS_SYNC_MSG: |
| 151 | /* |
| 152 | * Update driver statistics on connection sync. |
| 153 | */ |
| 154 | nss_ipv6_driver_conn_sync_update(nss_ctx, &nim->msg.conn_stats); |
Murat Sezgin | 5c8c736 | 2014-09-02 17:58:21 -0700 | [diff] [blame] | 155 | nss_rx_ipv6_sync(nss_ctx, &nim->msg.conn_stats); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 156 | break; |
Sakthi Vignesh Radhakrishnan | 515f8c2 | 2014-06-21 15:04:19 -0700 | [diff] [blame] | 157 | |
| 158 | case NSS_IPV6_TX_CREATE_RULE_MSG: |
| 159 | nss_rx_metadata_ipv6_create_response(nss_ctx, nim); |
| 160 | break; |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 161 | } |
Abhishek Rastogi | 55f3945 | 2014-05-08 19:23:29 +0530 | [diff] [blame] | 162 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 163 | /* |
| 164 | * Update the callback and app_data for NOTIFY messages, IPv6 sends all notify messages |
| 165 | * to the same callback/app_data. |
| 166 | */ |
| 167 | if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY) { |
| 168 | ncm->cb = (uint32_t)nss_ctx->nss_top->ipv6_callback; |
| 169 | ncm->app_data = (uint32_t)nss_ctx->nss_top->ipv6_ctx; |
| 170 | } |
| 171 | |
| 172 | /* |
| 173 | * Do we have a callback? |
| 174 | */ |
| 175 | if (!ncm->cb) { |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Callback |
| 181 | */ |
| 182 | cb = (nss_ipv6_msg_callback_t)ncm->cb; |
| 183 | cb((void *)ncm->app_data, nim); |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | * nss_ipv6_tx() |
| 188 | * Transmit an ipv6 message to the FW. |
| 189 | */ |
| 190 | nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim) |
| 191 | { |
| 192 | struct nss_ipv6_msg *nim2; |
| 193 | struct nss_cmn_msg *ncm = &nim->cm; |
| 194 | struct sk_buff *nbuf; |
| 195 | int32_t status; |
| 196 | |
| 197 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 198 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
| 199 | nss_warning("%p: ipv6 msg dropped as core not ready", nss_ctx); |
| 200 | return NSS_TX_FAILURE_NOT_READY; |
| 201 | } |
| 202 | |
| 203 | /* |
| 204 | * Sanity check the message |
| 205 | */ |
| 206 | if (ncm->interface != NSS_IPV6_RX_INTERFACE) { |
| 207 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 208 | return NSS_TX_FAILURE; |
| 209 | } |
| 210 | |
Murat Sezgin | 5c8c736 | 2014-09-02 17:58:21 -0700 | [diff] [blame] | 211 | if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 212 | nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); |
| 213 | return NSS_TX_FAILURE; |
| 214 | } |
| 215 | |
| 216 | if (ncm->len > sizeof(struct nss_ipv6_msg)) { |
| 217 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 218 | return NSS_TX_FAILURE; |
| 219 | } |
| 220 | |
Pamidipati, Vijay | b6e3884 | 2014-09-16 10:26:05 +0530 | [diff] [blame] | 221 | nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 222 | if (unlikely(!nbuf)) { |
| 223 | spin_lock_bh(&nss_ctx->nss_top->stats_lock); |
| 224 | nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]++; |
| 225 | spin_unlock_bh(&nss_ctx->nss_top->stats_lock); |
| 226 | nss_warning("%p: msg dropped as command allocation failed", nss_ctx); |
| 227 | return NSS_TX_FAILURE; |
| 228 | } |
| 229 | |
| 230 | /* |
| 231 | * Copy the message to our skb. |
| 232 | */ |
| 233 | nim2 = (struct nss_ipv6_msg *)skb_put(nbuf, sizeof(struct nss_ipv6_msg)); |
| 234 | memcpy(nim2, nim, sizeof(struct nss_ipv6_msg)); |
| 235 | |
| 236 | status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0); |
| 237 | if (status != NSS_CORE_STATUS_SUCCESS) { |
Pamidipati, Vijay | b6e3884 | 2014-09-16 10:26:05 +0530 | [diff] [blame] | 238 | dev_kfree_skb_any(nbuf); |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 239 | nss_warning("%p: Unable to enqueue 'Destroy IPv6' rule\n", nss_ctx); |
| 240 | return NSS_TX_FAILURE; |
| 241 | } |
| 242 | |
| 243 | nss_hal_send_interrupt(nss_ctx->nmap, nss_ctx->h2n_desc_rings[NSS_IF_CMD_QUEUE].desc_ring.int_bit, |
| 244 | NSS_REGS_H2N_INTR_STATUS_DATA_COMMAND_QUEUE); |
| 245 | |
| 246 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]); |
| 247 | return NSS_TX_SUCCESS; |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | ********************************** |
| 252 | Register/Unregister/Miscellaneous APIs |
| 253 | ********************************** |
| 254 | */ |
| 255 | |
| 256 | /* |
| 257 | * nss_ipv6_notify_register() |
| 258 | * Register to received IPv6 events. |
| 259 | * |
| 260 | * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? |
| 261 | */ |
| 262 | struct nss_ctx_instance *nss_ipv6_notify_register(nss_ipv6_msg_callback_t cb, void *app_data) |
| 263 | { |
| 264 | /* |
| 265 | * TODO: We need to have a new array in support of the new API |
| 266 | * TODO: If we use a per-context array, we would move the array into nss_ctx based. |
| 267 | */ |
| 268 | nss_top_main.ipv6_callback = cb; |
| 269 | nss_top_main.ipv6_ctx = app_data; |
| 270 | return &nss_top_main.nss[nss_top_main.ipv6_handler_id]; |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 | * nss_ipv6_notify_unregister() |
| 275 | * Unregister to received IPv6 events. |
| 276 | * |
| 277 | * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? |
| 278 | */ |
| 279 | void nss_ipv6_notify_unregister(void) |
| 280 | { |
| 281 | nss_top_main.ipv6_callback = NULL; |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | * nss_ipv6_get_mgr() |
| 286 | * |
| 287 | * TODO: This only suppports a single ipv6, do we ever want to support more? |
| 288 | */ |
| 289 | struct nss_ctx_instance *nss_ipv6_get_mgr(void) |
| 290 | { |
| 291 | return (void *)&nss_top_main.nss[nss_top_main.ipv6_handler_id]; |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | * nss_ipv6_register_handler() |
| 296 | * Register our handler to receive messages for this interface |
| 297 | */ |
| 298 | void nss_ipv6_register_handler() |
| 299 | { |
| 300 | if (nss_core_register_handler(NSS_IPV6_RX_INTERFACE, nss_ipv6_rx_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { |
| 301 | nss_warning("IPv6 handler failed to register"); |
| 302 | } |
| 303 | } |
| 304 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame^] | 305 | /* |
| 306 | * nss_ipv6_conn_cfg_callback() |
| 307 | * call back function for the ipv6 connection configuration handler |
| 308 | */ |
| 309 | static void nss_ipv6_conn_cfg_callback(void *app_data, struct nss_if_msg *nim) |
| 310 | { |
| 311 | if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 312 | nss_warning("IPv6 connection configuration failed with error: %d\n", nim->cm.error); |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | nss_info("IPv6 connection configuration success: %d\n", nim->cm.error); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | /* |
| 321 | * nss_ipv6_conn_cfg_handler() |
| 322 | * Sets the number of connections for IPv6 |
| 323 | */ |
| 324 | static int nss_ipv6_conn_cfg_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 325 | { |
| 326 | struct nss_top_instance *nss_top = &nss_top_main; |
| 327 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 328 | struct nss_ipv6_msg nim; |
| 329 | struct nss_ipv6_rule_conn_cfg_msg *nirccm; |
| 330 | nss_tx_status_t nss_tx_status; |
| 331 | int ret = 1; |
| 332 | uint32_t sum_of_conn = nss_ipv4_conn_cfg + nss_ipv6_conn_cfg; |
| 333 | |
| 334 | /* |
| 335 | * Specifications for input |
| 336 | * 1) The input should be power of 2. |
| 337 | * 2) Input for ipv4 and ipv6 sum togther should not exceed 8k |
| 338 | * 3) Min. value should be at leat 256 connections. This is the |
| 339 | * minimum connections we will support for each of them. |
| 340 | */ |
| 341 | if ((nss_ipv6_conn_cfg & (nss_ipv6_conn_cfg - 1)) || |
| 342 | (sum_of_conn > MAX_TOTAL_NUM_CONN_IPV4_IPV6) || |
| 343 | (nss_ipv6_conn_cfg < MIN_NUM_CONN)) { |
| 344 | nss_warning("%p: input supported connections (%d) does not adhere\ |
| 345 | specifications\n1) not power of 2,\n2) is less than \ |
| 346 | min val: %d, OR\n IPv4/6 total exceeds %d\n", |
| 347 | nss_ctx, |
| 348 | nss_ipv6_conn_cfg, |
| 349 | MIN_NUM_CONN, |
| 350 | MAX_TOTAL_NUM_CONN_IPV4_IPV6); |
| 351 | return ret; |
| 352 | } |
| 353 | |
| 354 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 355 | |
| 356 | if (ret) { |
| 357 | return ret; |
| 358 | } |
| 359 | |
| 360 | if (!write) { |
| 361 | nss_warning("%p: IPv6 supported connections write failed: %d\n", nss_ctx, nss_ipv6_conn_cfg); |
| 362 | return ret; |
| 363 | } |
| 364 | |
| 365 | nss_info("%p: IPv6 supported connections: %d\n", nss_ctx, nss_ipv6_conn_cfg); |
| 366 | |
| 367 | nss_cmn_msg_init(&nim.cm, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_CONN_CFG_RULE_MSG, |
| 368 | sizeof(struct nss_ipv6_rule_conn_cfg_msg), nss_ipv6_conn_cfg_callback, NULL); |
| 369 | |
| 370 | nirccm = &nim.msg.rule_conn_cfg; |
| 371 | nirccm->num_conn = htonl(nss_ipv6_conn_cfg); |
| 372 | nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); |
| 373 | |
| 374 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 375 | nss_warning("%p: nss_tx error setting IPv6 Connections: %d\n", |
| 376 | nss_ctx, |
| 377 | nss_ipv6_conn_cfg); |
| 378 | } |
| 379 | return ret; |
| 380 | } |
| 381 | |
| 382 | static ctl_table nss_ipv6_table[] = { |
| 383 | { |
| 384 | .procname = "ipv6_conn", |
| 385 | .data = &nss_ipv6_conn_cfg, |
| 386 | .maxlen = sizeof(int), |
| 387 | .mode = 0644, |
| 388 | .proc_handler = &nss_ipv6_conn_cfg_handler, |
| 389 | }, |
| 390 | { } |
| 391 | }; |
| 392 | |
| 393 | static ctl_table nss_ipv6_dir[] = { |
| 394 | { |
| 395 | .procname = "ipv6cfg", |
| 396 | .mode = 0555, |
| 397 | .child = nss_ipv6_table, |
| 398 | }, |
| 399 | { } |
| 400 | }; |
| 401 | |
| 402 | static ctl_table nss_ipv6_root_dir[] = { |
| 403 | { |
| 404 | .procname = "nss", |
| 405 | .mode = 0555, |
| 406 | .child = nss_ipv6_dir, |
| 407 | }, |
| 408 | { } |
| 409 | }; |
| 410 | |
| 411 | static ctl_table nss_ipv6_root[] = { |
| 412 | { |
| 413 | .procname = "dev", |
| 414 | .mode = 0555, |
| 415 | .child = nss_ipv6_root_dir, |
| 416 | }, |
| 417 | { } |
| 418 | }; |
| 419 | |
| 420 | static struct ctl_table_header *nss_ipv6_header; |
| 421 | |
| 422 | /* |
| 423 | * nss_ipv6_register_sysctl() |
| 424 | * Register sysctl specific to ipv4 |
| 425 | */ |
| 426 | void nss_ipv6_register_sysctl(void) |
| 427 | { |
| 428 | /* |
| 429 | * Register sysctl table. |
| 430 | */ |
| 431 | nss_ipv6_header = register_sysctl_table(nss_ipv6_root); |
| 432 | } |
| 433 | |
| 434 | /* |
| 435 | * nss_ipv6_unregister_sysctl() |
| 436 | * Unregister sysctl specific to ipv4 |
| 437 | */ |
| 438 | void nss_ipv6_unregister_sysctl(void) |
| 439 | { |
| 440 | /* |
| 441 | * Unregister sysctl table. |
| 442 | */ |
| 443 | if (nss_ipv6_header) { |
| 444 | unregister_sysctl_table(nss_ipv6_header); |
| 445 | } |
| 446 | } |
| 447 | |
Sol Kavy | 879eb8b | 2014-04-07 19:11:31 -0700 | [diff] [blame] | 448 | EXPORT_SYMBOL(nss_ipv6_tx); |
| 449 | EXPORT_SYMBOL(nss_ipv6_notify_register); |
| 450 | EXPORT_SYMBOL(nss_ipv6_notify_unregister); |
| 451 | EXPORT_SYMBOL(nss_ipv6_get_mgr); |
| 452 | EXPORT_SYMBOL(nss_ipv6_register_handler); |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame^] | 453 | EXPORT_SYMBOL(nss_ipv6_register_sysctl); |
| 454 | EXPORT_SYMBOL(nss_ipv6_unregister_sysctl); |