[qca-nss-drv] C2C fix for running IPsec
The changes fixes the following
- C2C enum mismatch which caused the TX_MAP not being programmed at FW
- IPsec API register problem which resulted in NULL context
- DEBUG enabled driver fails compilation issue
CRs-Fixed:657386
Change-Id: I2bb583859ade69e8bf7383c2132bdedde5e6b0cc
Signed-off-by: Samarjeet Banerjee <banerjee@codeaurora.org>
diff --git a/Makefile b/Makefile
index 6baefbc..f18c266 100644
--- a/Makefile
+++ b/Makefile
@@ -43,13 +43,11 @@
# TODO: Deprecated files should be removed before merge
#
qca-nss-drv-objs += \
- nss_tx_rx_crypto.o \
nss_tx_rx_eth_rx.o \
nss_tx_rx_freq.o \
nss_tx_rx_generic.o \
nss_tx_rx_ipv4.o \
nss_tx_rx_ipv6.o \
- nss_tx_rx_ipsec.o \
nss_tx_rx_n2h.o \
nss_tx_rx_pppoe.o \
nss_tx_rx_phys_if.o \
diff --git a/exports/nss_api_if.h b/exports/nss_api_if.h
index cf3469c..1f89222 100644
--- a/exports/nss_api_if.h
+++ b/exports/nss_api_if.h
@@ -729,69 +729,6 @@
extern nss_tx_status_t nss_tx_destroy_ipv6_rule(void *nss_ctx, struct nss_ipv6_destroy *unid);
/**
- * Methods provided by NSS device driver for use by crypto driver
- */
-
-/**
- * Callback to receive crypto buffers
- */
-typedef void (*nss_crypto_data_callback_t)(void *ctx, void *buf, uint32_t buf_paddr, uint16_t len);
-
-/**
- * Callback to receive crypto sync messages
- */
-typedef void (*nss_crypto_sync_callback_t)(void *ctx, void *buf, uint32_t len);
-
-/**
- * @brief Register for sending/receiving crypto buffers
- *
- * @param crypto_data_callback data callback
- * @param crypto_sync_callback sync callback
- * @param ctx Crypto context
- *
- * @return void* NSS context to be provided with every message
- */
-extern void *nss_register_crypto_if(nss_crypto_data_callback_t crypto_data_callback, void *ctx);
-
-/**
- * @brief Register for sending/receiving crypto sync messages
- *
- * @param crypto_data_callback data callback
- * @param crypto_sync_callback sync callback
- * @param ctx Crypto context
- *
- */
-extern void nss_register_crypto_sync_if(nss_crypto_sync_callback_t crypto_sync_callback, void *ctx);
-
-/**
- * @brief Unregister for sending/receiving crypto buffers
- */
-extern void nss_unregister_crypto_if(void);
-
-/**
- * @brief Configure crypto interface
- *
- * @param ctx NSS context
- * @param buf Buffer to send to NSS
- * @param len Length of buffer
- *
- * @return nss_tx_status_t Tx status
- */
-extern nss_tx_status_t nss_tx_crypto_if_open(void *ctx, uint8_t *buf, uint32_t len);
-
-/**
- * @brief Send crypto buffer to NSS
- *
- * @param nss_ctx NSS context
- * @param buf Crypto buffer
- * @param buf_paddr Physical address of buffer
- * @param len Length of buffer
- *
- * @return nss_tx_status_t Tx status
- */
-extern nss_tx_status_t nss_tx_crypto_if_buf(void *nss_ctx, void *buf, uint32_t buf_paddr, uint16_t len);
-
-/**
* Methods provided by NSS device driver for use by GMAC driver
*/
@@ -956,58 +893,6 @@
extern nss_tx_status_t nss_tx_virt_if_rxbuf(void *nss_ctx, struct sk_buff *os_buf);
/**
- * Methods provided by NSS driver for use by IPsec stack
- */
-
-/**
- * Callback to receive IPsec events
- */
-typedef void (*nss_ipsec_event_callback_t)(void *if_ctx, uint32_t if_num, void *buf, uint32_t len);
-
-/**
- * Callback to receive ipsec data message
- */
-typedef void (*nss_ipsec_data_callback_t)(void *ctx, void *os_buf);
-
-/**
- * @brief Register to send/receive IPsec data to NSS
- *
- * @param ipsec interface number if_num
- * @param ipsec_data callback ipsec_data_cb
- * @param ctx IPsec context
- *
- * @return void* NSS context
- */
-extern void *nss_register_ipsec_if(uint32_t if_num, nss_ipsec_data_callback_t ipsec_data_cb, void *ctx);
-
-/**
- * @brief Register to send/receive IPsec events to NSS
- *
- * @param ipsec interface number if_num
- * @param ipsec_data callback ipsec_data_cb
- *
- */
-extern void nss_register_ipsec_event_if(uint32_t if_num, nss_ipsec_event_callback_t ipsec_event_cb);
-
-/**
- * @brief Unregister IPsec interface with NSS
- */
-extern void nss_unregister_ipsec_if(uint32_t if_num);
-
-/**
- * @brief Send rule creation message for IPsec Tx node
- *
- * @param nss_ctx NSS context
- * @param interface_num interface number for Ipsec tunnel
- * @param type IPsec rule type
- * @param buf Rule buffer that needs to be sent to NSS
- * @param len Length of valid data in buffer
- *
- * @return nss_tx_status_t Tx status
- */
-extern nss_tx_status_t nss_tx_ipsec_rule(void *nss_ctx, uint32_t interface_num, uint32_t type, uint8_t *buf, uint32_t len);
-
-/**
* Methods provided by NSS driver for use by NSS Profiler
*/
diff --git a/nss_crypto.c b/nss_crypto.c
index d58c7ce..fe44ba6 100644
--- a/nss_crypto.c
+++ b/nss_crypto.c
@@ -73,7 +73,7 @@
nss_crypto_buf_callback_t cb = nss_top->crypto_buf_callback;
if (unlikely(!cb)) {
- nss_crypto_trace("%p: rx data handler has been unregistered for i/f: %d", nss_ctx, ncm->interface);
+ nss_crypto_trace("%p: rx data handler has been unregistered for i/f", nss_ctx);
return;
}
@@ -186,6 +186,9 @@
return NSS_TX_FAILURE;
}
+ nss_crypto_info("msg params version:%d, interface:%d, type:%d, cb:%d, app_data:%d, len:%d\n",
+ ncm->version, ncm->interface, ncm->type, ncm->cb, ncm->app_data, ncm->len);
+
nim = (struct nss_crypto_msg *)skb_put(nbuf, sizeof(struct nss_crypto_msg));
memcpy(nim, msg, sizeof(struct nss_crypto_msg));
diff --git a/nss_hlos_if.h b/nss_hlos_if.h
index db6aad6..a8de05d 100644
--- a/nss_hlos_if.h
+++ b/nss_hlos_if.h
@@ -169,7 +169,8 @@
* Request/Response types
*/
enum nss_c2c_metadata_types {
- NSS_TX_METADATA_TYPE_C2C_TX_MAP,
+ NSS_TX_METADATA_TYPE_NONE = 0,
+ NSS_TX_METADATA_TYPE_C2C_TX_MAP = 1,
NSS_METADATA_TYPE_C2C_MAX,
};
diff --git a/nss_init.c b/nss_init.c
index bbdd7fd..8525d54 100644
--- a/nss_init.c
+++ b/nss_init.c
@@ -141,7 +141,7 @@
} else if (nss_dev->id == 1) {
rc = request_firmware(&nss_fw, NETAP1_IMAGE, &(nss_dev->dev));
} else {
- nss_warning("%p: Invalid nss dev: %d \n", nss_dev->id);
+ nss_warning("%p: Invalid nss dev: %d \n", nss_ctx, nss_dev->id);
}
/*
diff --git a/nss_ipsec.c b/nss_ipsec.c
index bb951a5..78a32e3 100644
--- a/nss_ipsec.c
+++ b/nss_ipsec.c
@@ -47,10 +47,12 @@
case NSS_IPSEC_ENCAP_IF_NUMBER:
nss_top->ipsec_encap_ctx = ipsec_ctx;
nss_top->ipsec_encap_callback = cb;
+ break;
case NSS_IPSEC_DECAP_IF_NUMBER:
nss_top->ipsec_decap_ctx = ipsec_ctx;
nss_top->ipsec_decap_callback = cb;
+ break;
default:
nss_ipsec_warning("%p: cannot 'set' message callback, incorrect I/F: %d", nss_ctx, if_num);
@@ -206,6 +208,9 @@
return NSS_TX_FAILURE;
}
+ nss_ipsec_info("msg params version:%d, interface:%d, type:%d, cb:%d, app_data:%d, len:%d\n",
+ ncm->version, ncm->interface, ncm->type, ncm->cb, ncm->app_data, ncm->len);
+
nim = (struct nss_ipsec_msg *)skb_put(nbuf, sizeof(struct nss_ipsec_msg));
memcpy(nim, msg, sizeof(struct nss_ipsec_msg));
diff --git a/nss_tx_rx_crypto.c b/nss_tx_rx_crypto.c
deleted file mode 100644
index c5f34c5..0000000
--- a/nss_tx_rx_crypto.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- **************************************************************************
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all copies.
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- **************************************************************************
- */
-
-/*
- * nss_tx_rx_crypto.c
- * NSS crypto APIs
- */
-
-#include "nss_tx_rx_common.h"
-
-/*
- **********************************
- Tx APIs
- **********************************
- */
-
-/*
- * nss_tx_crypto_if_open()
- * NSS crypto configure API.
- */
-nss_tx_status_t nss_tx_crypto_if_open(void *ctx, uint8_t *buf, uint32_t len)
-{
- nss_warning("%p: deprecated crypto API(s):%s, switch to newer ones\n", nss_ctx, __func__);
- return NSS_TX_SUCCESS;
-}
-
-/*
- * nss_tx_crypto_if_buf()
- * NSS crypto Tx API. Sends a crypto buffer to NSS.
- */
-nss_tx_status_t nss_tx_crypto_if_buf(void *ctx, void *buf, uint32_t buf_paddr, uint16_t len)
-{
- nss_warning("%p: deprecated crypto API(s):%s, switch to newer ones\n", nss_ctx, __func__);
- return NSS_TX_SUCCESS;
-}
-
-
-/*
- **********************************
- Register/Unregister/Miscellaneous APIs
- **********************************
- */
-
-/*
- * nss_register_crypto_mgr()
- */
-void *nss_register_crypto_if(nss_crypto_data_callback_t crypto_data_callback, void *ctx)
-{
- nss_top_main.crypto_ctx = ctx;
-
- nss_warning("deprecated crypto API(s):%s, switch to newer ones\n", __func__);
-
- return (void *)&nss_top_main.nss[nss_top_main.crypto_handler_id];
-}
-
-/*
- * nss_register_crypto_sync_if()
- */
-void nss_register_crypto_sync_if(nss_crypto_sync_callback_t crypto_sync_callback, void *ctx)
-{
- nss_warning("deprecated crypto API(s):%s, switch to newer ones\n", __func__);
-
- nss_top_main.crypto_ctx = ctx;
-}
-
-/*
- * nss_unregister_crypto_mgr()
- */
-void nss_unregister_crypto_if(void)
-{
- nss_warning("deprecated crypto API(s):%s, switch to newer ones\n", __func__);
- nss_top_main.crypto_ctx = NULL;
-}
-
-
-EXPORT_SYMBOL(nss_register_crypto_if);
-EXPORT_SYMBOL(nss_register_crypto_sync_if);
-EXPORT_SYMBOL(nss_unregister_crypto_if);
-EXPORT_SYMBOL(nss_tx_crypto_if_buf);
-EXPORT_SYMBOL(nss_tx_crypto_if_open);
diff --git a/nss_tx_rx_ipsec.c b/nss_tx_rx_ipsec.c
deleted file mode 100644
index 96aeb79..0000000
--- a/nss_tx_rx_ipsec.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- **************************************************************************
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all copies.
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- **************************************************************************
- */
-
-/*
- * nss_tx_rx_ipsec.c
- * NSS IPsec APIs
- */
-
-#include "nss_tx_rx_common.h"
-
-/*
- **********************************
- Tx APIs
- **********************************
- */
-
-/*
- * nss_tx_ipsec_rule
- * Send ipsec rule to NSS.
- */
-nss_tx_status_t nss_tx_ipsec_rule(void *ctx, uint32_t interface_num, uint32_t type, uint8_t *buf, uint32_t len)
-{
- nss_warning("%p:deprecated API(s), switch to newer ones\n", ctx);
-
- return NSS_TX_FAILURE;
-}
-
-/*
- **********************************
- Register/Unregister/Miscellaneous APIs
- **********************************
- */
-
-/*
- * nss_register_ipsec_if()
- */
-void *nss_register_ipsec_if(uint32_t if_num,
- nss_ipsec_data_callback_t ipsec_data_cb,
- void *if_ctx)
-{
- nss_assert((if_num >= NSS_MAX_PHYSICAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES));
-
- nss_top_main.if_ctx[if_num] = if_ctx;
- nss_top_main.if_rx_callback[if_num] = ipsec_data_cb;
-
- return (void *)&nss_top_main.nss[nss_top_main.ipsec_handler_id];
-}
-
-/*
- * nss_register_ipsec_event_if()
- */
-void nss_register_ipsec_event_if(uint32_t if_num, nss_ipsec_event_callback_t ipsec_event_cb)
-{
- nss_assert((if_num >= NSS_MAX_PHYSICAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES));
- nss_warning("%p:deprecated API(s), switch to newer ones : %d\n", nss_ctx, if_num);
-
-}
-
-/*
- * nss_unregister_ipsec_if()
- */
-void nss_unregister_ipsec_if(uint32_t if_num)
-{
- nss_assert((if_num >= NSS_MAX_PHYSICAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES));
-
- nss_top_main.if_rx_callback[if_num] = NULL;
- nss_top_main.if_ctx[if_num] = NULL;
-
- nss_warning("%p:deprecated API(s), switch to newer ones : %d\n", nss_ctx, if_num);
-}
-
-EXPORT_SYMBOL(nss_register_ipsec_if);
-EXPORT_SYMBOL(nss_register_ipsec_event_if);
-EXPORT_SYMBOL(nss_unregister_ipsec_if);
-EXPORT_SYMBOL(nss_tx_ipsec_rule);
diff --git a/nss_virt_if.c b/nss_virt_if.c
index 96ee4b2..f13c44d 100644
--- a/nss_virt_if.c
+++ b/nss_virt_if.c
@@ -219,7 +219,7 @@
spin_lock_bh(&nss_ctx->nss_top->stats_lock);
nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]++;
spin_unlock_bh(&nss_ctx->nss_top->stats_lock);
- nss_warning("%p: virtual interface %p: command allocation failed", nss_ctx, dev);
+ nss_warning("%p: virtual interface %d: command allocation failed", nss_ctx, ncm->interface);
return NSS_TX_FAILURE;
}