Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 3 | * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [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_ipsec.c |
| 19 | * NSS IPsec APIs |
| 20 | */ |
| 21 | |
| 22 | #include "nss_tx_rx_common.h" |
Murat Sezgin | ea1a435 | 2014-04-15 19:09:51 -0700 | [diff] [blame] | 23 | #include "nss_ipsec.h" |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 24 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 25 | #if defined(NSS_HAL_IPQ806X_SUPPORT) |
| 26 | #define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_ENCAP_IF_NUMBER |
| 27 | #define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_DECAP_IF_NUMBER |
| 28 | #define NSS_IPSEC_DATA_INTERFACE_NUM NSS_C2C_TX_INTERFACE |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 29 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 30 | #elif defined(NSS_HAL_FSM9010_SUPPORT) |
| 31 | #define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_ENCAP_IF_NUMBER |
| 32 | #define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_DECAP_IF_NUMBER |
| 33 | #define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_RULE_INTERFACE |
| 34 | |
| 35 | #elif defined(NSS_HAL_IPQ807x_SUPPORT) |
| 36 | #define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_RULE_INTERFACE |
| 37 | #define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_RULE_INTERFACE |
| 38 | #define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_RULE_INTERFACE |
| 39 | |
| 40 | #else |
| 41 | #define NSS_IPSEC_ENCAP_INTERFACE_NUM -1 |
| 42 | #define NSS_IPSEC_DECAP_INTERFACE_NUM -1 |
| 43 | #define NSS_IPSEC_DATA_INTERFACE_NUM -1 |
| 44 | |
| 45 | #endif |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 46 | |
| 47 | /* |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 48 | * Amount time the synchronous message should wait for response from |
| 49 | * NSS before the timeout happens. After the timeout the message |
| 50 | * response even if it arrives has to be discarded. Typically, the |
| 51 | * time needs to be selected based on the worst case time in case of |
| 52 | * peak throughput between host & NSS. |
| 53 | */ |
| 54 | #define NSS_IPSEC_TX_TIMEO_TICKS msecs_to_jiffies(3000) /* 3 Seconds */ |
| 55 | |
| 56 | /* |
| 57 | * Private data structure to hold state for |
| 58 | * the ipsec specific NSS interaction |
| 59 | */ |
| 60 | struct nss_ipsec_pvt { |
| 61 | struct semaphore sem; /* used for synchronizing 'tx_msg_sync' */ |
| 62 | struct completion complete; /* completion callback */ |
| 63 | atomic_t resp; /* Response error type */ |
| 64 | } nss_ipsec; |
| 65 | |
| 66 | /* |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 67 | * nss_ipsec_get_msg_ctx() |
| 68 | * return ipsec message context assoicated with the callback |
| 69 | * |
| 70 | * Note: certain SOC the decap interface specially programmed |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 71 | */ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 72 | static inline nss_ptr_t nss_ipsec_get_msg_ctx(struct nss_ctx_instance *nss_ctx, uint32_t interface_num) |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 73 | { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 74 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 75 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 76 | /* |
| 77 | * the encap is primary interface |
| 78 | */ |
Sourav Poddar | eb8cb65 | 2017-05-18 12:02:18 +0530 | [diff] [blame] | 79 | if (interface_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 80 | return (nss_ptr_t)nss_top->ipsec_encap_ctx; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 81 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 82 | return (nss_ptr_t)nss_top->ipsec_decap_ctx; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
| 86 | * nss_ipsec_get_msg_callback() |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 87 | * this gets the message callback handler |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 88 | */ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 89 | static inline nss_ptr_t nss_ipsec_get_msg_callback(struct nss_ctx_instance *nss_ctx, uint32_t interface_num) |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 90 | { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 91 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 92 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 93 | /* |
| 94 | * the encap is primary interface |
| 95 | */ |
Sourav Poddar | eb8cb65 | 2017-05-18 12:02:18 +0530 | [diff] [blame] | 96 | if (interface_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 97 | return (nss_ptr_t)nss_top->ipsec_encap_callback; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 98 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 99 | return (nss_ptr_t)nss_top->ipsec_decap_callback; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* |
| 103 | ********************************** |
| 104 | Rx APIs |
| 105 | ********************************** |
| 106 | */ |
| 107 | |
| 108 | /* |
| 109 | * nss_ipsec_msg_handler() |
| 110 | * this handles all the IPsec events and responses |
| 111 | */ |
| 112 | static void nss_ipsec_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data __attribute((unused))) |
| 113 | { |
| 114 | struct nss_ipsec_msg *nim = (struct nss_ipsec_msg *)ncm; |
| 115 | nss_ipsec_msg_callback_t cb = NULL; |
| 116 | uint32_t if_num = ncm->interface; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 117 | |
| 118 | /* |
| 119 | * Sanity check the message type |
| 120 | */ |
| 121 | if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 122 | nss_warning("%p: rx message type out of range: %d", nss_ctx, ncm->type); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 123 | return; |
| 124 | } |
| 125 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 126 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipsec_msg)) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 127 | nss_warning("%p: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 128 | return; |
| 129 | } |
| 130 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 131 | BUG_ON((if_num != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (if_num != NSS_IPSEC_DECAP_INTERFACE_NUM)); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 132 | |
| 133 | if (ncm->response == NSS_CMN_RESPONSE_LAST) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 134 | nss_warning("%p: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 135 | ncm->type, ncm->response); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * Is this a notification? if, yes then fill up the callback and app_data from |
| 141 | * locally stored state |
| 142 | */ |
| 143 | if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 144 | ncm->cb = nss_ipsec_get_msg_callback(nss_ctx, if_num); |
| 145 | ncm->app_data = nss_ipsec_get_msg_ctx(nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 146 | } |
| 147 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 148 | nss_core_log_msg_failures(nss_ctx, ncm); |
| 149 | |
| 150 | /* |
| 151 | * load, test & call |
| 152 | */ |
| 153 | cb = (nss_ipsec_msg_callback_t)ncm->cb; |
| 154 | if (unlikely(!cb)) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 155 | nss_trace("%p: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 156 | return; |
| 157 | } |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 158 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 159 | cb((void *)ncm->app_data, nim); |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | ********************************** |
| 164 | Tx APIs |
| 165 | ********************************** |
| 166 | */ |
| 167 | |
| 168 | /* |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 169 | * nss_ipsec_callback() |
| 170 | * Callback to handle the completion of NSS->HLOS messages. |
| 171 | */ |
| 172 | static void nss_ipsec_callback(void *app_data, struct nss_ipsec_msg *nim) |
| 173 | { |
| 174 | struct nss_cmn_msg *ncm = &nim->cm; |
| 175 | |
| 176 | /* |
| 177 | * This callback is for synchronous operation. The caller sends its |
| 178 | * response pointer which needs to be loaded with the response |
| 179 | * data arriving from the NSS |
| 180 | */ |
| 181 | atomic_t *resp = (atomic_t *)app_data; |
| 182 | |
| 183 | if (ncm->response == NSS_CMN_RESPONSE_ACK) { |
| 184 | atomic_set(resp, NSS_IPSEC_ERROR_TYPE_NONE); |
| 185 | complete(&nss_ipsec.complete); |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | atomic_set(resp, ncm->error); |
| 190 | complete(&nss_ipsec.complete); |
| 191 | } |
| 192 | |
| 193 | /* |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 194 | * nss_ipsec_tx_msg |
| 195 | * Send ipsec rule to NSS. |
| 196 | */ |
| 197 | nss_tx_status_t nss_ipsec_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ipsec_msg *msg) |
| 198 | { |
| 199 | struct nss_cmn_msg *ncm = &msg->cm; |
| 200 | struct nss_ipsec_msg *nim; |
| 201 | struct sk_buff *nbuf; |
| 202 | int32_t status; |
| 203 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 204 | nss_info("%p: message %d for if %d\n", nss_ctx, ncm->type, ncm->interface); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 205 | |
| 206 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 207 | |
| 208 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 209 | nss_warning("%p: tx message dropped as core not ready", nss_ctx); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 210 | return NSS_TX_FAILURE_NOT_READY; |
| 211 | } |
| 212 | |
Tanmay V Jagdale | f6b2bce | 2017-03-03 14:31:07 +0530 | [diff] [blame] | 213 | BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_ipsec_msg)); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 214 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 215 | if ((ncm->interface != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (ncm->interface != NSS_IPSEC_DECAP_INTERFACE_NUM)) { |
| 216 | nss_warning("%p: tx message request for another interface: %d", nss_ctx, ncm->interface); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 217 | return NSS_TX_FAILURE; |
| 218 | } |
| 219 | |
| 220 | if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 221 | nss_warning("%p: tx message type out of range: %d", nss_ctx, ncm->type); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 222 | return NSS_TX_FAILURE; |
| 223 | } |
| 224 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 225 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipsec_msg)) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 226 | nss_warning("%p: tx message request len for if %d, is bad: %d", nss_ctx, ncm->interface, nss_cmn_get_msg_len(ncm)); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 227 | return NSS_TX_FAILURE_BAD_PARAM; |
| 228 | } |
| 229 | |
Pamidipati, Vijay | b6e3884 | 2014-09-16 10:26:05 +0530 | [diff] [blame] | 230 | nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 231 | if (unlikely(!nbuf)) { |
Sundarajan Srinivasan | 62fee7e | 2015-01-22 11:13:10 -0800 | [diff] [blame] | 232 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]); |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 233 | nss_warning("%p: tx rule dropped as command allocation failed", nss_ctx); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 234 | return NSS_TX_FAILURE; |
| 235 | } |
| 236 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 237 | nss_info("msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d\n", |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 238 | ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len); |
Samarjeet Banerjee | 7bce8c5 | 2014-05-02 15:32:13 +0530 | [diff] [blame] | 239 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 240 | nim = (struct nss_ipsec_msg *)skb_put(nbuf, sizeof(struct nss_ipsec_msg)); |
| 241 | memcpy(nim, msg, sizeof(struct nss_ipsec_msg)); |
| 242 | |
| 243 | status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0); |
| 244 | if (status != NSS_CORE_STATUS_SUCCESS) { |
Pamidipati, Vijay | b6e3884 | 2014-09-16 10:26:05 +0530 | [diff] [blame] | 245 | dev_kfree_skb_any(nbuf); |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 246 | nss_warning("%p: tx Unable to enqueue message \n", nss_ctx); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 247 | return NSS_TX_FAILURE; |
| 248 | } |
| 249 | |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 250 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 251 | |
| 252 | return NSS_TX_SUCCESS; |
| 253 | } |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 254 | EXPORT_SYMBOL(nss_ipsec_tx_msg); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 255 | |
| 256 | /* |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 257 | * nss_ipsec_tx_msg_sync() |
| 258 | * Transmit a ipsec message to NSS firmware synchronously. |
| 259 | */ |
| 260 | nss_tx_status_t nss_ipsec_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, |
| 261 | enum nss_ipsec_msg_type type, uint16_t len, |
| 262 | struct nss_ipsec_msg *nim, enum nss_ipsec_error_type *resp) |
| 263 | { |
| 264 | struct nss_ipsec_msg nim_local = { {0} }; |
| 265 | nss_tx_status_t status; |
| 266 | int ret; |
| 267 | |
| 268 | /* |
| 269 | * Length of the message should be the based on type |
| 270 | */ |
| 271 | if (len > sizeof(nim_local.msg)) { |
| 272 | nss_warning("%p: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); |
| 273 | return NSS_TX_FAILURE_TOO_LARGE; |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | * Response buffer is a required for copying the response for message |
| 278 | */ |
| 279 | if (!resp) { |
| 280 | nss_warning("%p: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); |
| 281 | return NSS_TX_FAILURE_BAD_PARAM; |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | * TODO: this can be removed in future as we need to ensure that the response |
| 286 | * memory is only updated when the current outstanding request is waiting. |
| 287 | * This can be solved by introducing sequence no. in messages and only completing |
| 288 | * the message if the sequence no. matches. For now this is solved by passing |
| 289 | * a known memory nss_ipsec.resp |
| 290 | */ |
| 291 | down(&nss_ipsec.sem); |
| 292 | |
| 293 | /* |
| 294 | * Initializing it to a fail error type |
| 295 | */ |
| 296 | atomic_set(&nss_ipsec.resp, NSS_IPSEC_ERROR_TYPE_UNHANDLED_MSG); |
| 297 | |
| 298 | /* |
| 299 | * We need to copy the message content into the actual message |
| 300 | * to be sent to NSS |
| 301 | * |
| 302 | * Note: Here pass the nss_ipsec.resp as the pointer. Since, the caller |
| 303 | * provided pointer is not allocated by us and may go away when this function |
| 304 | * returns with failure. The callback is not aware of this and may try to |
| 305 | * access the pointer incorrectly potentially resulting in a crash. |
| 306 | */ |
| 307 | nss_ipsec_msg_init(&nim_local, if_num, type, len, nss_ipsec_callback, &nss_ipsec.resp); |
| 308 | memcpy(&nim_local.msg, &nim->msg, len); |
| 309 | |
| 310 | status = nss_ipsec_tx_msg(nss_ctx, &nim_local); |
| 311 | if (status != NSS_TX_SUCCESS) { |
| 312 | nss_warning("%p: ipsec_tx_msg failed", nss_ctx); |
| 313 | goto done; |
| 314 | } |
| 315 | |
| 316 | ret = wait_for_completion_timeout(&nss_ipsec.complete, NSS_IPSEC_TX_TIMEO_TICKS); |
| 317 | if (!ret) { |
| 318 | nss_warning("%p: IPsec msg tx failed due to timeout", nss_ctx); |
| 319 | status = NSS_TX_FAILURE_NOT_ENABLED; |
| 320 | goto done; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Read memory barrier |
| 325 | */ |
| 326 | smp_rmb(); |
| 327 | |
| 328 | /* |
| 329 | * Copy the response received |
| 330 | */ |
| 331 | *resp = atomic_read(&nss_ipsec.resp); |
| 332 | |
| 333 | /* |
| 334 | * Only in case of non-error response we will |
| 335 | * indicate success |
| 336 | */ |
| 337 | if (*resp != NSS_IPSEC_ERROR_TYPE_NONE) |
| 338 | status = NSS_TX_FAILURE; |
| 339 | |
| 340 | done: |
| 341 | up(&nss_ipsec.sem); |
| 342 | return status; |
| 343 | } |
| 344 | EXPORT_SYMBOL(nss_ipsec_tx_msg_sync); |
| 345 | |
| 346 | /* |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 347 | * nss_ipsec_tx_buf |
| 348 | * Send data packet for ipsec processing |
| 349 | */ |
Stephen Wang | 83e4875 | 2015-03-03 18:41:40 -0800 | [diff] [blame] | 350 | nss_tx_status_t nss_ipsec_tx_buf(struct sk_buff *skb, uint32_t if_num) |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 351 | { |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 352 | struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 353 | int32_t status; |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 354 | |
Stephen Wang | 83e4875 | 2015-03-03 18:41:40 -0800 | [diff] [blame] | 355 | nss_trace("%p: IPsec If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data); |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 356 | |
| 357 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 358 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
| 359 | nss_warning("%p: 'IPsec If Tx' packet dropped as core not ready", nss_ctx); |
| 360 | return NSS_TX_FAILURE_NOT_READY; |
| 361 | } |
| 362 | |
Stephen Wang | 83e4875 | 2015-03-03 18:41:40 -0800 | [diff] [blame] | 363 | status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_DATA_QUEUE_0, H2N_BUFFER_PACKET, 0); |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 364 | if (unlikely(status != NSS_CORE_STATUS_SUCCESS)) { |
| 365 | nss_warning("%p: Unable to enqueue 'IPsec If Tx' packet\n", nss_ctx); |
| 366 | if (status == NSS_CORE_STATUS_FAILURE_QUEUE) { |
| 367 | return NSS_TX_FAILURE_QUEUE; |
| 368 | } |
| 369 | |
| 370 | return NSS_TX_FAILURE; |
| 371 | } |
| 372 | |
| 373 | /* |
| 374 | * Kick the NSS awake so it can process our new entry. |
| 375 | */ |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 376 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); |
Radha krishna Simha Jiguru | d36b1e2 | 2014-09-12 15:14:52 +0530 | [diff] [blame] | 377 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_PACKET]); |
| 378 | return NSS_TX_SUCCESS; |
| 379 | } |
| 380 | EXPORT_SYMBOL(nss_ipsec_tx_buf); |
| 381 | |
| 382 | /* |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 383 | ********************************** |
| 384 | Register APIs |
| 385 | ********************************** |
| 386 | */ |
| 387 | |
| 388 | /* |
Ankit Dhanuka | a0e4cae | 2014-05-26 16:33:10 +0530 | [diff] [blame] | 389 | * nss_ipsec_notify_register() |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 390 | * register message notifier for the given interface (if_num) |
| 391 | */ |
| 392 | struct nss_ctx_instance *nss_ipsec_notify_register(uint32_t if_num, nss_ipsec_msg_callback_t cb, void *app_data) |
| 393 | { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 394 | struct nss_top_instance *nss_top = &nss_top_main; |
| 395 | uint8_t core_id = nss_top->ipsec_handler_id; |
| 396 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id]; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 397 | |
| 398 | if (if_num >= NSS_MAX_NET_INTERFACES) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 399 | nss_warning("%p: notfiy register received for invalid interface %d", nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 400 | return NULL; |
| 401 | } |
| 402 | |
Samarjeet Banerjee | 940e91b | 2016-03-29 19:23:17 +0530 | [diff] [blame] | 403 | /* |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 404 | * the encap is primary interface |
Samarjeet Banerjee | 940e91b | 2016-03-29 19:23:17 +0530 | [diff] [blame] | 405 | */ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 406 | if (if_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) { |
| 407 | nss_top->ipsec_encap_callback = cb; |
| 408 | nss_top->ipsec_encap_ctx = app_data; |
Samarjeet Banerjee | 940e91b | 2016-03-29 19:23:17 +0530 | [diff] [blame] | 409 | return nss_ctx; |
| 410 | } |
| 411 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 412 | nss_top->ipsec_decap_callback = cb; |
| 413 | nss_top->ipsec_decap_ctx = app_data; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 414 | return nss_ctx; |
| 415 | } |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 416 | EXPORT_SYMBOL(nss_ipsec_notify_register); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 417 | |
| 418 | /* |
Ankit Dhanuka | a0e4cae | 2014-05-26 16:33:10 +0530 | [diff] [blame] | 419 | * nss_ipsec_notify_unregister() |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 420 | * unregister the IPsec notifier for the given interface number (if_num) |
| 421 | */ |
| 422 | void nss_ipsec_notify_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) |
| 423 | { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 424 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
| 425 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 426 | if (if_num >= NSS_MAX_NET_INTERFACES) { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 427 | nss_warning("%p: notify unregister received for invalid interface %d", nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 428 | return; |
| 429 | } |
| 430 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 431 | /* |
| 432 | * the encap is primary interface |
| 433 | */ |
| 434 | if (if_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) { |
| 435 | nss_top->ipsec_encap_callback = NULL; |
| 436 | nss_top->ipsec_encap_ctx = NULL; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 437 | return; |
| 438 | } |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 439 | |
| 440 | nss_top->ipsec_decap_callback = NULL; |
| 441 | nss_top->ipsec_decap_ctx = NULL; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 442 | } |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 443 | EXPORT_SYMBOL(nss_ipsec_notify_unregister); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 444 | |
| 445 | /* |
Ankit Dhanuka | a0e4cae | 2014-05-26 16:33:10 +0530 | [diff] [blame] | 446 | * nss_ipsec_data_register() |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 447 | * register a data callback routine |
| 448 | */ |
Sundarajan Srinivasan | 7037484 | 2014-11-19 15:22:52 -0800 | [diff] [blame] | 449 | struct nss_ctx_instance *nss_ipsec_data_register(uint32_t if_num, nss_ipsec_buf_callback_t cb, struct net_device *netdev, uint32_t features) |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 450 | { |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 451 | struct nss_ctx_instance *nss_ctx, *nss_ctx0; |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 452 | |
| 453 | nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; |
| 454 | |
| 455 | if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)){ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 456 | nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 457 | return NULL; |
| 458 | } |
| 459 | |
Samarjeet Banerjee | 940e91b | 2016-03-29 19:23:17 +0530 | [diff] [blame] | 460 | /* |
| 461 | * avoid multiple registeration for multiple tunnels |
| 462 | */ |
Stephen Wang | 84e0e99 | 2016-09-07 12:31:40 -0700 | [diff] [blame] | 463 | if (nss_ctx->subsys_dp_register[if_num].cb) { |
Samarjeet Banerjee | 940e91b | 2016-03-29 19:23:17 +0530 | [diff] [blame] | 464 | return nss_ctx; |
| 465 | } |
| 466 | |
Jackson Bockus | 7ca70ec | 2017-07-17 13:47:29 -0700 | [diff] [blame] | 467 | nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, NULL, netdev, features); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 468 | |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 469 | if (nss_top_main.ipsec_handler_id == 1) { |
| 470 | nss_ctx0 = &nss_top_main.nss[0]; |
| 471 | |
Jackson Bockus | 7ca70ec | 2017-07-17 13:47:29 -0700 | [diff] [blame] | 472 | nss_core_register_subsys_dp(nss_ctx0, if_num, cb, NULL, NULL, netdev, features); |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 473 | } |
| 474 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 475 | return nss_ctx; |
| 476 | } |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 477 | EXPORT_SYMBOL(nss_ipsec_data_register); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 478 | |
| 479 | /* |
Ankit Dhanuka | a0e4cae | 2014-05-26 16:33:10 +0530 | [diff] [blame] | 480 | * nss_ipsec_data_unregister() |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 481 | * unregister a data callback routine |
| 482 | */ |
| 483 | void nss_ipsec_data_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) |
| 484 | { |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 485 | struct nss_ctx_instance *nss_ctx0; |
| 486 | |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 487 | if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)){ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 488 | nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 489 | return; |
| 490 | } |
| 491 | |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 492 | if (nss_top_main.ipsec_handler_id == 1) { |
| 493 | nss_ctx0 = &nss_top_main.nss[0]; |
| 494 | |
Jackson Bockus | 7ca70ec | 2017-07-17 13:47:29 -0700 | [diff] [blame] | 495 | nss_core_unregister_subsys_dp(nss_ctx0, if_num); |
Arunkumar T | 657c406 | 2016-09-21 18:06:48 +0530 | [diff] [blame] | 496 | } |
| 497 | |
Jackson Bockus | 7ca70ec | 2017-07-17 13:47:29 -0700 | [diff] [blame] | 498 | nss_core_unregister_subsys_dp(nss_ctx, if_num); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 499 | } |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 500 | EXPORT_SYMBOL(nss_ipsec_data_unregister); |
| 501 | |
| 502 | /* |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 503 | * nss_ipsec_get_encap_interface() |
| 504 | * Get the NSS interface number for encap message |
Radha krishna Simha Jiguru | db7ad24 | 2014-11-19 16:02:23 +0530 | [diff] [blame] | 505 | */ |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 506 | int32_t nss_ipsec_get_encap_interface(void) |
Radha krishna Simha Jiguru | db7ad24 | 2014-11-19 16:02:23 +0530 | [diff] [blame] | 507 | { |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 508 | return NSS_IPSEC_ENCAP_INTERFACE_NUM; |
Radha krishna Simha Jiguru | db7ad24 | 2014-11-19 16:02:23 +0530 | [diff] [blame] | 509 | } |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 510 | EXPORT_SYMBOL(nss_ipsec_get_encap_interface); |
| 511 | |
| 512 | /* |
| 513 | * nss_ipsec_get_decap_interface() |
| 514 | * Get the NSS interface number for decap message |
| 515 | */ |
| 516 | int32_t nss_ipsec_get_decap_interface(void) |
| 517 | { |
| 518 | return NSS_IPSEC_DECAP_INTERFACE_NUM; |
| 519 | } |
| 520 | EXPORT_SYMBOL(nss_ipsec_get_decap_interface); |
| 521 | |
| 522 | /* |
| 523 | * nss_ipsec_get_data_interface() |
| 524 | * Get the NSS interface number used for data path |
| 525 | */ |
| 526 | int32_t nss_ipsec_get_data_interface(void) |
| 527 | { |
| 528 | return NSS_IPSEC_DATA_INTERFACE_NUM; |
| 529 | } |
| 530 | EXPORT_SYMBOL(nss_ipsec_get_data_interface); |
Radha krishna Simha Jiguru | db7ad24 | 2014-11-19 16:02:23 +0530 | [diff] [blame] | 531 | |
| 532 | /* |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame] | 533 | * nss_ipsec_get_context() |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 534 | * Get NSS context instance for IPsec handle |
Samarjeet Banerjee | 7733231 | 2014-08-07 14:48:22 +0530 | [diff] [blame] | 535 | */ |
| 536 | struct nss_ctx_instance *nss_ipsec_get_context(void) |
| 537 | { |
| 538 | return &nss_top_main.nss[nss_top_main.ipsec_handler_id]; |
| 539 | } |
| 540 | EXPORT_SYMBOL(nss_ipsec_get_context); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 541 | |
| 542 | /* |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 543 | * nss_ipsec_ppe_port_config() |
| 544 | * Configure PPE port for IPsec inline |
| 545 | */ |
| 546 | bool nss_ipsec_ppe_port_config(struct nss_ctx_instance *nss_ctx, struct net_device *dev, |
| 547 | uint32_t if_num, uint32_t vsi_num) |
| 548 | { |
| 549 | #ifdef NSS_PPE_SUPPORTED |
| 550 | if_num = NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); |
| 551 | |
| 552 | if (nss_ppe_tx_ipsec_config_msg(if_num, vsi_num, dev->mtu) != NSS_TX_SUCCESS) { |
| 553 | nss_warning("%p: Failed to configure PPE IPsec port", nss_ctx); |
| 554 | return false; |
| 555 | } |
| 556 | |
| 557 | return true; |
| 558 | #else |
| 559 | return false; |
| 560 | #endif |
| 561 | } |
| 562 | EXPORT_SYMBOL(nss_ipsec_ppe_port_config); |
| 563 | |
| 564 | /* |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 565 | * nss_ipsec_register_handler() |
| 566 | */ |
| 567 | void nss_ipsec_register_handler() |
| 568 | { |
| 569 | struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; |
| 570 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 571 | BUILD_BUG_ON(NSS_IPSEC_ENCAP_INTERFACE_NUM < 0); |
| 572 | BUILD_BUG_ON(NSS_IPSEC_DECAP_INTERFACE_NUM < 0); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 573 | |
Vijay Vigneshan | b809f42 | 2018-04-04 15:04:35 +0530 | [diff] [blame^] | 574 | sema_init(&nss_ipsec.sem, 1); |
| 575 | init_completion(&nss_ipsec.complete); |
| 576 | atomic_set(&nss_ipsec.resp, NSS_IPSEC_ERROR_TYPE_NONE); |
| 577 | |
Sourav Poddar | bf8b50c | 2017-02-15 12:44:44 +0530 | [diff] [blame] | 578 | nss_ctx->nss_top->ipsec_encap_callback = NULL; |
| 579 | nss_ctx->nss_top->ipsec_decap_callback = NULL; |
| 580 | |
| 581 | nss_ctx->nss_top->ipsec_encap_ctx = NULL; |
| 582 | nss_ctx->nss_top->ipsec_decap_ctx = NULL; |
| 583 | |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame] | 584 | nss_core_register_handler(nss_ctx, NSS_IPSEC_ENCAP_INTERFACE_NUM, nss_ipsec_msg_handler, NULL); |
| 585 | nss_core_register_handler(nss_ctx, NSS_IPSEC_DECAP_INTERFACE_NUM, nss_ipsec_msg_handler, NULL); |
Samarjeet Banerjee | d99d9d0 | 2014-04-08 18:51:00 +0530 | [diff] [blame] | 586 | } |
| 587 | |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 588 | /* |
| 589 | * nss_ipsec_msg_init() |
| 590 | * Initialize ipsec message. |
| 591 | */ |
| 592 | void nss_ipsec_msg_init(struct nss_ipsec_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, |
Sundarajan Srinivasan | 30a53d4 | 2015-01-30 10:52:08 -0800 | [diff] [blame] | 593 | nss_ipsec_msg_callback_t cb, void *app_data) |
Sundarajan Srinivasan | 02e6c2b | 2014-10-06 11:51:12 -0700 | [diff] [blame] | 594 | { |
| 595 | nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); |
| 596 | } |
| 597 | EXPORT_SYMBOL(nss_ipsec_msg_init); |