mirror of
https://github.com/qosmio/nss-packages.git
synced 2025-12-17 00:33:40 +00:00
394 lines
14 KiB
Diff
394 lines
14 KiB
Diff
--- a/exports/nss_tunipip6.h
|
|
+++ b/exports/nss_tunipip6.h
|
|
@@ -1,6 +1,6 @@
|
|
/*
|
|
**************************************************************************
|
|
- * Copyright (c) 2014, 2017-2018, 2020, The Linux Foundation. All rights reserved.
|
|
+ * Copyright (c) 2014, 2017-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.
|
|
@@ -30,18 +30,16 @@
|
|
#define NSS_TUNIPIP6_MAX_FMR_NUMBER 4 /**< Maximum number of forward mapping rule (FMR). */
|
|
|
|
/**
|
|
- * nss_tunipip6_map_rule
|
|
- * Mapping rule (FMR/BMR) for forwarding traffic to the node in the same domain.
|
|
+ * nss_tunipip6_fmr
|
|
+ * Forward mapping rule (FMR) for direct forwarding traffic to the node in the same domain.
|
|
*/
|
|
-struct nss_tunipip6_map_rule {
|
|
+struct nss_tunipip6_fmr {
|
|
uint32_t ip6_prefix[4]; /**< An IPv6 prefix assigned by a mapping rule. */
|
|
uint32_t ip4_prefix; /**< An IPv4 prefix assigned by a mapping rule. */
|
|
uint32_t ip6_prefix_len; /**< IPv6 prefix length. */
|
|
uint32_t ip4_prefix_len; /**< IPv4 prefix length. */
|
|
- uint32_t ip6_suffix[4]; /**< IPv6 suffix. */
|
|
- uint32_t ip6_suffix_len; /**< IPv6 suffix length. */
|
|
uint32_t ea_len; /**< Embedded Address (EA) bits. */
|
|
- uint32_t psid_offset; /**< PSID offset default 6. */
|
|
+ uint32_t offset; /**< PSID offset default 6. */
|
|
};
|
|
|
|
/**
|
|
@@ -52,11 +50,6 @@ enum nss_tunipip6_metadata_types {
|
|
NSS_TUNIPIP6_TX_ENCAP_IF_CREATE,
|
|
NSS_TUNIPIP6_TX_DECAP_IF_CREATE,
|
|
NSS_TUNIPIP6_RX_STATS_SYNC,
|
|
- NSS_TUNIPIP6_FMR_RULE_ADD,
|
|
- NSS_TUNIPIP6_FMR_RULE_DEL,
|
|
- NSS_TUNIPIP6_FMR_RULE_FLUSH,
|
|
- NSS_TUNIPIP6_BMR_RULE_ADD,
|
|
- NSS_TUNIPIP6_BMR_RULE_DEL,
|
|
NSS_TUNIPIP6_MAX,
|
|
};
|
|
|
|
@@ -65,16 +58,16 @@ enum nss_tunipip6_metadata_types {
|
|
* Payload for configuring the DS-Lite interface.
|
|
*/
|
|
struct nss_tunipip6_create_msg {
|
|
+ struct nss_tunipip6_fmr fmr[NSS_TUNIPIP6_MAX_FMR_NUMBER]; /**< Tunnel FMR array. */
|
|
uint32_t saddr[4]; /**< Tunnel source address. */
|
|
uint32_t daddr[4]; /**< Tunnel destination address. */
|
|
uint32_t flowlabel; /**< Tunnel IPv6 flow label. */
|
|
uint32_t flags; /**< Tunnel additional flags. */
|
|
+ uint32_t fmr_number; /**< Tunnel FMR number. */
|
|
uint32_t sibling_if_num; /**< Sibling interface number. */
|
|
+ uint16_t reserved1; /**< Reserved for alignment. */
|
|
uint8_t hop_limit; /**< Tunnel IPv6 hop limit. */
|
|
uint8_t draft03; /**< Use MAP-E draft03 specification. */
|
|
- bool ttl_inherit; /**< Inherit IPv4 TTL to hoplimit. */
|
|
- bool tos_inherit; /**< Inherit IPv4 ToS. */
|
|
- bool frag_id_update; /**< Enable update of fragment identifier of IPv4. */
|
|
};
|
|
|
|
/**
|
|
@@ -97,12 +90,10 @@ struct nss_tunipip6_msg {
|
|
*/
|
|
union {
|
|
struct nss_tunipip6_create_msg tunipip6_create;
|
|
- /**< Create a DS-Lite/IPIP6 tunnel. */
|
|
+ /**< Create a DS-Lite tunnel. */
|
|
struct nss_tunipip6_stats_sync_msg stats_sync;
|
|
/**< Synchronized statistics for the DS-Lite interface. */
|
|
- struct nss_tunipip6_map_rule map_rule;
|
|
- /**< BMR/FMR rule to add/delete, new or existing rules. */
|
|
- } msg; /**< Message payload for IPIP6 tunnel messages exchanged with NSS core. */
|
|
+ } msg; /**< Message payload for IPIP6 Tunnel messages exchanged with NSS core. */
|
|
};
|
|
|
|
/**
|
|
@@ -133,22 +124,6 @@ typedef void (*nss_tunipip6_msg_callback
|
|
extern nss_tx_status_t nss_tunipip6_tx(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg);
|
|
|
|
/**
|
|
- * nss_tunipip6_tx_sync
|
|
- * Sends a DS-Lite message to NSS core synchronously.
|
|
- *
|
|
- * @datatypes
|
|
- * nss_ctx_instance \n
|
|
- * nss_tunipip6_msg
|
|
- *
|
|
- * @param[in] nss_ctx Pointer to the NSS context.
|
|
- * @param[in] msg Pointer to the message data.
|
|
- *
|
|
- * @return
|
|
- * Status of the Tx operation.
|
|
- */
|
|
-extern nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg);
|
|
-
|
|
-/**
|
|
* Callback function for receiving DS-Lite data.
|
|
*
|
|
* @datatypes
|
|
--- a/nss_tunipip6.c
|
|
+++ b/nss_tunipip6.c
|
|
@@ -1,6 +1,6 @@
|
|
/*
|
|
**************************************************************************
|
|
- * Copyright (c) 2014-2018, 2020, The Linux Foundation. All rights reserved.
|
|
+ * Copyright (c) 2014-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.
|
|
@@ -17,19 +17,6 @@
|
|
#include "nss_tx_rx_common.h"
|
|
#include "nss_tunipip6_log.h"
|
|
|
|
-#define NSS_TUNIPIP6_TX_TIMEOUT 3000
|
|
-
|
|
-/*
|
|
- * Data structure used to handle sync message.
|
|
- */
|
|
-static struct nss_tunipip6_pvt {
|
|
- struct semaphore sem; /* Semaphore structure. */
|
|
- struct completion complete; /* Completion structure. */
|
|
- int response; /* Response from FW. */
|
|
- void *cb; /* Original cb for msgs. */
|
|
- void *app_data; /* Original app_data for msgs. */
|
|
-} tunipip6_pvt;
|
|
-
|
|
/*
|
|
* nss_tunipip6_verify_if_num
|
|
* Verify the interface is a valid interface
|
|
@@ -70,12 +57,12 @@ static void nss_tunipip6_handler(struct
|
|
* Is this a valid request/response packet?
|
|
*/
|
|
if (ncm->type >= NSS_TUNIPIP6_MAX) {
|
|
- nss_warning("%px: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type);
|
|
+ nss_warning("%p: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type);
|
|
return;
|
|
}
|
|
|
|
if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tunipip6_msg)) {
|
|
- nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
|
|
+ nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
|
|
return;
|
|
}
|
|
|
|
@@ -109,7 +96,7 @@ static void nss_tunipip6_handler(struct
|
|
* call ipip6 tunnel callback
|
|
*/
|
|
if (!ctx) {
|
|
- nss_warning("%px: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface);
|
|
+ nss_warning("%p: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface);
|
|
return;
|
|
}
|
|
|
|
@@ -133,12 +120,12 @@ nss_tx_status_t nss_tunipip6_tx(struct n
|
|
* Sanity check the message
|
|
*/
|
|
if (!nss_tunipip6_verify_if_num(ncm->interface)) {
|
|
- nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface);
|
|
+ nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface);
|
|
return NSS_TX_FAILURE;
|
|
}
|
|
|
|
if (ncm->type > NSS_TUNIPIP6_MAX) {
|
|
- nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type);
|
|
+ nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
|
|
return NSS_TX_FAILURE;
|
|
}
|
|
|
|
@@ -147,60 +134,6 @@ nss_tx_status_t nss_tunipip6_tx(struct n
|
|
EXPORT_SYMBOL(nss_tunipip6_tx);
|
|
|
|
/*
|
|
- * nss_tunipip6_callback()
|
|
- * Callback to handle the completion of NSS->HLOS messages.
|
|
- */
|
|
-static void nss_tunipip6_callback(void *app_data, struct nss_tunipip6_msg *nclm)
|
|
-{
|
|
- tunipip6_pvt.response = NSS_TX_SUCCESS;
|
|
- tunipip6_pvt.cb = NULL;
|
|
- tunipip6_pvt.app_data = NULL;
|
|
-
|
|
- if (nclm->cm.response != NSS_CMN_RESPONSE_ACK) {
|
|
- nss_warning("%px: tunipip6 Error response %d Error: %d\n", app_data, nclm->cm.response, nclm->cm.error);
|
|
- tunipip6_pvt.response = nclm->cm.response;
|
|
- }
|
|
-
|
|
- /*
|
|
- * Write memory barrier.
|
|
- */
|
|
- smp_wmb();
|
|
- complete(&tunipip6_pvt.complete);
|
|
-}
|
|
-
|
|
-/*
|
|
- * nss_tunipip6_tx_sync()
|
|
- * Transmit a tunipip6 message to NSSFW synchronously.
|
|
- */
|
|
-nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg)
|
|
-{
|
|
- nss_tx_status_t status;
|
|
- int ret;
|
|
-
|
|
- down(&tunipip6_pvt.sem);
|
|
- msg->cm.cb = (nss_ptr_t)nss_tunipip6_callback;
|
|
- msg->cm.app_data = (nss_ptr_t)NULL;
|
|
-
|
|
- status = nss_tunipip6_tx(nss_ctx, msg);
|
|
- if (status != NSS_TX_SUCCESS) {
|
|
- nss_warning("%px: tunipip6_tx_msg failed\n", nss_ctx);
|
|
- up(&tunipip6_pvt.sem);
|
|
- return status;
|
|
- }
|
|
-
|
|
- ret = wait_for_completion_timeout(&tunipip6_pvt.complete, msecs_to_jiffies(NSS_TUNIPIP6_TX_TIMEOUT));
|
|
- if (!ret) {
|
|
- nss_warning("%px: tunipip6 tx sync failed due to timeout\n", nss_ctx);
|
|
- tunipip6_pvt.response = NSS_TX_FAILURE;
|
|
- }
|
|
-
|
|
- status = tunipip6_pvt.response;
|
|
- up(&tunipip6_pvt.sem);
|
|
- return status;
|
|
-}
|
|
-EXPORT_SYMBOL(nss_tunipip6_tx_sync);
|
|
-
|
|
-/*
|
|
* **********************************
|
|
* Register/Unregister/Miscellaneous APIs
|
|
* **********************************
|
|
@@ -264,8 +197,6 @@ void nss_tunipip6_register_handler()
|
|
struct nss_ctx_instance *nss_ctx = nss_tunipip6_get_context();
|
|
|
|
nss_core_register_handler(nss_ctx, NSS_TUNIPIP6_INTERFACE, nss_tunipip6_handler, NULL);
|
|
- sema_init(&tunipip6_pvt.sem, 1);
|
|
- init_completion(&tunipip6_pvt.complete);
|
|
}
|
|
|
|
/*
|
|
--- a/nss_tunipip6_log.c
|
|
+++ b/nss_tunipip6_log.c
|
|
@@ -1,6 +1,6 @@
|
|
/*
|
|
**************************************************************************
|
|
- * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved.
|
|
+ * Copyright (c) 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.
|
|
@@ -26,63 +26,47 @@
|
|
* NSS TUNIPIP6 message strings
|
|
*/
|
|
static int8_t *nss_tunipip6_log_message_types_str[NSS_TUNIPIP6_MAX] __maybe_unused = {
|
|
- "TUNIPIP6 Encap Interface Create",
|
|
- "TUNIPIP6 Decap Interface Create",
|
|
+ "TUNIPIP6 Interface Create",
|
|
"TUNIPIP6 Stats",
|
|
- "TUNIPIP6 FMR add",
|
|
- "TUNIPIP6 FMR delete",
|
|
- "TUNIPIP6 FMR flush",
|
|
- "TUNIPIP6 BMR add",
|
|
- "TUNIPIP6 BMR delete",
|
|
};
|
|
|
|
/*
|
|
- * nss_tunipip6_log_map_rule()
|
|
- * Log NSS TUNIPIP6 map rule.
|
|
- */
|
|
-static void nss_tunipip6_log_map_rule(struct nss_tunipip6_msg *ntm)
|
|
-{
|
|
- struct nss_tunipip6_map_rule *nmr __maybe_unused = &ntm->msg.map_rule;
|
|
- nss_trace("%px: NSS TUNIPIP6 Interface Create message \n"
|
|
- "TUNIPIP6 Map Rule IPv6 prefix: %pI6\n"
|
|
- "TUNIPIP6 Map Rule IPv6 prefix length: %d\n"
|
|
- "TUNIPIP6 Map Rule IPv4 prefix: %pI4\n"
|
|
- "TUNIPIP6 Map Rule IPv4 prefix length: %d\n"
|
|
- "TUNIPIP6 Map Rule IPv6 suffix: %pI6\n"
|
|
- "TUNIPIP6 Map Rule IPv6 suffix length: %d\n"
|
|
- "TUNIPIP6 Map Rule EA length: %d\n"
|
|
- "TUNIPIP6 Map Rule PSID offset: %d\n",
|
|
- nmr, nmr->ip6_prefix,
|
|
- nmr->ip6_prefix_len,&nmr->ip4_prefix,
|
|
- nmr->ip4_prefix_len, nmr->ip6_suffix,
|
|
- nmr->ip6_suffix_len, nmr->ea_len,
|
|
- nmr->psid_offset);
|
|
-}
|
|
-
|
|
-/*
|
|
* nss_tunipip6_log_if_create_msg()
|
|
* Log NSS TUNIPIP6 Interface Create
|
|
*/
|
|
static void nss_tunipip6_log_if_create_msg(struct nss_tunipip6_msg *ntm)
|
|
{
|
|
struct nss_tunipip6_create_msg *ntcm __maybe_unused = &ntm->msg.tunipip6_create;
|
|
- nss_trace("%px: NSS TUNIPIP6 Interface Create message \n"
|
|
+ int32_t i;
|
|
+ nss_trace("%p: NSS TUNIPIP6 Interface Create message \n"
|
|
"TUNIPIP6 Source Address: %pI6\n"
|
|
"TUNIPIP6 Destination Address: %pI6\n"
|
|
"TUNIPIP6 Flow Label: %d\n"
|
|
"TUNIPIP6 Flags: %d\n"
|
|
"TUNIPIP6 Hop Limit: %d\n"
|
|
"TUNIPIP6 Draft03 Specification: %d\n"
|
|
- "TUNIPIP6 TTL inherit: %s\n"
|
|
- "TUNIPIP6 TOS inherit: %s\n"
|
|
- "TUNIPIP6 Frag ID Update: %s\n",
|
|
+ "TUNIPIP6 FMR Number: %d\n",
|
|
ntcm, ntcm->saddr,
|
|
ntcm->daddr, ntcm->flowlabel,
|
|
ntcm->flags, ntcm->hop_limit,
|
|
- ntcm->draft03,
|
|
- ntcm->ttl_inherit ? "true":"false",
|
|
- ntcm->tos_inherit ? "true":"false",
|
|
- ntcm->frag_id_update ? "true":"false");
|
|
+ ntcm->draft03, ntcm->fmr_number);
|
|
+ /*
|
|
+ * Continuation of the log.
|
|
+ */
|
|
+ for (i = 0; i < NSS_TUNIPIP6_MAX_FMR_NUMBER; i++) {
|
|
+ nss_trace("TUNIPIP6 FMR[%d] IPv6 Prefix: %pI6\n"
|
|
+ "TUNIPIP6 FMR[%d] IPv4 Prefix: %pI4\n"
|
|
+ "TUNIPIP6 FMR[%d] IPv6 Prefix Length: %d\n"
|
|
+ "TUNIPIP6 FMR[%d] IPv4 Prefix Length: %d\n"
|
|
+ "TUNIPIP6 FMR[%d] Embedded Address Length: %d\n"
|
|
+ "TUNIPIP6 FMR[%d] offset: %d",
|
|
+ i, ntcm->fmr[i].ip6_prefix,
|
|
+ i, &ntcm->fmr[i].ip4_prefix,
|
|
+ i, ntcm->fmr[i].ip6_prefix_len,
|
|
+ i, ntcm->fmr[i].ip4_prefix_len,
|
|
+ i, ntcm->fmr[i].ea_len,
|
|
+ i, ntcm->fmr[i].offset);
|
|
+ }
|
|
}
|
|
|
|
/*
|
|
@@ -103,17 +87,8 @@ static void nss_tunipip6_log_verbose(str
|
|
*/
|
|
break;
|
|
|
|
- case NSS_TUNIPIP6_BMR_RULE_ADD:
|
|
- case NSS_TUNIPIP6_BMR_RULE_DEL:
|
|
- case NSS_TUNIPIP6_FMR_RULE_ADD:
|
|
- case NSS_TUNIPIP6_FMR_RULE_DEL:
|
|
- nss_tunipip6_log_map_rule(ntm);
|
|
- break;
|
|
- case NSS_TUNIPIP6_FMR_RULE_FLUSH:
|
|
- nss_trace("%px: FMR rule flush.\n", ntm);
|
|
- break;
|
|
default:
|
|
- nss_trace("%px: Invalid message type\n", ntm);
|
|
+ nss_trace("%p: Invalid message type\n", ntm);
|
|
break;
|
|
}
|
|
}
|
|
@@ -125,11 +100,11 @@ static void nss_tunipip6_log_verbose(str
|
|
void nss_tunipip6_log_tx_msg(struct nss_tunipip6_msg *ntm)
|
|
{
|
|
if (ntm->cm.type >= NSS_TUNIPIP6_MAX) {
|
|
- nss_warning("%px: Invalid message type\n", ntm);
|
|
+ nss_warning("%p: Invalid message type\n", ntm);
|
|
return;
|
|
}
|
|
|
|
- nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]);
|
|
+ nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]);
|
|
nss_tunipip6_log_verbose(ntm);
|
|
}
|
|
|
|
@@ -140,18 +115,18 @@ void nss_tunipip6_log_tx_msg(struct nss_
|
|
void nss_tunipip6_log_rx_msg(struct nss_tunipip6_msg *ntm)
|
|
{
|
|
if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) {
|
|
- nss_warning("%px: Invalid response\n", ntm);
|
|
+ nss_warning("%p: Invalid response\n", ntm);
|
|
return;
|
|
}
|
|
|
|
if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) {
|
|
- nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type,
|
|
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type,
|
|
nss_tunipip6_log_message_types_str[ntm->cm.type],
|
|
ntm->cm.response, nss_cmn_response_str[ntm->cm.response]);
|
|
goto verbose;
|
|
}
|
|
|
|
- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n",
|
|
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n",
|
|
ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type],
|
|
ntm->cm.response, nss_cmn_response_str[ntm->cm.response]);
|
|
|