From d9934448830e31f46ebe0db90d9bb16ec15469d3 Mon Sep 17 00:00:00 2001 From: hari-selvam <98732013+hari-selvam@users.noreply.github.com> Date: Thu, 8 Dec 2022 06:44:34 +0530 Subject: [PATCH] [sflow]: Unblocked psample_*() function calls in BRCM ESW platforms for proper functionality of sflow feature (#12918) *Replaced BRCM SDK's psample support flag(PSAMPLE_SUPPORT) with linux kernel psample module support config flag(CONFIG_PSAMPLE) in saibcm-modules. *Replaced BUILD_PSAMPLE conditioanl check with CONFIG_PSAMPLE to build psample callback library(psample-cb.o), only if psample config is enabled in linux kernel. *Cleaned up PSAMPLE_SUPPORT related commented code. Signed-off-by: haris@celestica.com Signed-off-by: haris@celestica.com --- .../saibcm-modules/sdklt/linux/knetcb/Kbuild | 3 +-- .../sdklt/linux/knetcb/ngknetcb_main.c | 12 ++++++------ .../sdklt/linux/knetcb/psample-cb.h | 1 - .../linux/kernel/modules/knet-cb/knet-cb.c | 18 +++++++++--------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild index 6a60777e9c48..e14e25669cff 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild @@ -17,8 +17,7 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # -ifeq ($(BUILD_PSAMPLE),1) -PSAMPLE_CFLAGS=-DPSAMPLE_SUPPORT +ifneq ($(CONFIG_PSAMPLE),) PSAMPLE_CB_OBJS=psample-cb.o endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c index c456ebbdf73e..af2a0c9aef3d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c @@ -307,8 +307,8 @@ static struct sk_buff * ngknet_rx_cb(struct sk_buff *skb) { skb = strip_tag_rx_cb(skb); -#ifdef PSAMPLE_SUPPORT - skb = psample_rx_cb(skb); +#if IS_ENABLED(CONFIG_PSAMPLE) + skb = psample_rx_cb(skb); #endif return skb; } @@ -324,7 +324,7 @@ static int ngknet_netif_create_cb(struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(dev); #endif return retv; @@ -334,7 +334,7 @@ static int ngknet_netif_destroy_cb(struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(dev); #endif return retv; @@ -431,7 +431,7 @@ ngknetcb_init_module(void) ngknet_rx_cb_register(ngknet_rx_cb); ngknet_tx_cb_register(ngknet_tx_cb); -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_init(); #endif @@ -446,7 +446,7 @@ ngknetcb_exit_module(void) ngknet_netif_create_cb_unregister(ngknet_netif_create_cb); ngknet_netif_destroy_cb_unregister(ngknet_netif_destroy_cb); -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_cleanup(); #endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h index 2e3342ead5c3..e2922a36bca4 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h @@ -24,7 +24,6 @@ #include #include -//#define PSAMPLE_SUPPORT 1 // TODO: MLI@BRCM - Add this as part of conditional in Makefile #define PSAMPLE_CB_NAME "psample" extern int diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c index 297ef7a1e478..b420e30a3729 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c @@ -46,7 +46,7 @@ #include /* Enable sflow sampling using psample */ -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) #include "psample-cb.h" #endif @@ -334,7 +334,7 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t *kf) { /* check for filter callback handler */ -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) if (strncmp(kf->desc, PSAMPLE_CB_NAME, strlen(PSAMPLE_CB_NAME)) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -346,7 +346,7 @@ static int knet_netif_create_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(unit, netif, spa, dev); #endif return retv; @@ -356,7 +356,7 @@ static int knet_netif_destroy_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(unit, netif, spa, dev); #endif return retv; @@ -367,7 +367,7 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t *kf) { /* check for filter callback handler */ -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) if (strncmp(kf->desc, PSAMPLE_CB_NAME, KCOM_FILTER_DESC_MAX) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -379,7 +379,7 @@ static int knet_netif_create_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_create_cb(unit, netif, dev); #endif return retv; @@ -389,7 +389,7 @@ static int knet_netif_destroy_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) retv = psample_netif_destroy_cb(unit, netif, dev); #endif return retv; @@ -427,7 +427,7 @@ _cleanup(void) bkn_netif_create_cb_unregister(knet_netif_create_cb); bkn_netif_destroy_cb_unregister(knet_netif_destroy_cb); -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_cleanup(); #endif return 0; @@ -445,7 +445,7 @@ _init(void) bkn_tx_skb_cb_register(strip_tag_tx_cb); } -#ifdef PSAMPLE_SUPPORT +#if IS_ENABLED(CONFIG_PSAMPLE) psample_init(); #endif bkn_filter_cb_register(knet_filter_cb);