[qca-nss-drv] Split host to NSS command/data queues
Change-Id: I30a4215fe7742262cd6a7b0c2bd0865ce6dffd7f
Signed-off-by: Stephen Wang <wstephen@codeaurora.org>
diff --git a/nss_pptp.c b/nss_pptp.c
index 8af8ef2..bcd2979 100644
--- a/nss_pptp.c
+++ b/nss_pptp.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2018, 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.
@@ -182,16 +182,7 @@
*/
static nss_tx_status_t nss_pptp_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pptp_msg *msg)
{
- struct nss_pptp_msg *nm;
struct nss_cmn_msg *ncm = &msg->cm;
- struct sk_buff *nbuf;
- int32_t status;
-
- NSS_VERIFY_CTX_MAGIC(nss_ctx);
- if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
- nss_warning("%p: pptp msg dropped as core not ready", nss_ctx);
- return NSS_TX_FAILURE_NOT_READY;
- }
/*
* Sanity check the message
@@ -206,38 +197,7 @@
return NSS_TX_FAILURE;
}
- if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pptp_msg)) {
- nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
- return NSS_TX_FAILURE;
- }
-
- nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
- if (unlikely(!nbuf)) {
- NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]);
- nss_warning("%p: msg dropped as command allocation failed", nss_ctx);
- return NSS_TX_FAILURE;
- }
-
- /*
- * Copy the message to our skb
- */
- nm = (struct nss_pptp_msg *)skb_put(nbuf, sizeof(struct nss_pptp_msg));
- memcpy(nm, msg, sizeof(struct nss_pptp_msg));
-
- status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
- if (status != NSS_CORE_STATUS_SUCCESS) {
- dev_kfree_skb_any(nbuf);
- nss_warning("%p: Unable to enqueue 'pptp message'\n", nss_ctx);
- if (status == NSS_CORE_STATUS_FAILURE_QUEUE) {
- return NSS_TX_FAILURE_QUEUE;
- }
- return NSS_TX_FAILURE;
- }
-
- nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
-
- NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]);
- return NSS_TX_SUCCESS;
+ return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE);
}
/*
@@ -314,29 +274,9 @@
*/
nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb)
{
- int32_t status;
-
nss_trace("%p: pptp If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data);
- NSS_VERIFY_CTX_MAGIC(nss_ctx);
- if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
- nss_warning("%p: 'PPTP' packet dropped as core not ready", nss_ctx);
- return NSS_TX_FAILURE_NOT_READY;
- }
-
- status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_DATA_QUEUE_0, H2N_BUFFER_PACKET, H2N_BIT_FLAG_VIRTUAL_BUFFER);
- if (unlikely(status != NSS_CORE_STATUS_SUCCESS)) {
- nss_warning("%p: Unable to enqueue 'PPTP' packet\n", nss_ctx);
- return NSS_TX_FAILURE_QUEUE;
- }
-
- /*
- * Kick the NSS awake so it can process our new entry.
- */
- nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
-
- NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_PACKET]);
- return NSS_TX_SUCCESS;
+ return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER);
}
/*