Skip to content

Commit

Permalink
[sflow]: Unblocked psample_*() function calls in BRCM ESW platforms f…
Browse files Browse the repository at this point in the history
…or proper functionality of sflow feature (sonic-net#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
  • Loading branch information
hari-selvam authored and mssonicbld committed Feb 6, 2023
1 parent fa5f03b commit d2ee305
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
3 changes: 1 addition & 2 deletions platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <lkm/lkm.h>
#include <linux/netdevice.h>

//#define PSAMPLE_SUPPORT 1 // TODO: MLI@BRCM - Add this as part of conditional in Makefile
#define PSAMPLE_CB_NAME "psample"

extern int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <linux/if_vlan.h>

/* Enable sflow sampling using psample */
#ifdef PSAMPLE_SUPPORT
#if IS_ENABLED(CONFIG_PSAMPLE)
#include "psample-cb.h"
#endif

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit d2ee305

Please sign in to comment.