Skip to content

Commit aa911f4

Browse files
authored
saibcm-modules trixie support (#30)
* [trixie] handle kernel feature string, sonic With respect to linux-headers for ARCH vs. COMMON KVER_ARCH := $(KVER)-sonic-amd64 KVER_COMMON := $(KVER)-common-sonic * kernel 6.12.x compile
1 parent c7c9f7f commit aa911f4

12 files changed

Lines changed: 52 additions & 49 deletions

File tree

platform/broadcom/saibcm-modules/debian/rules

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ sname:=opennsl
3434
PACKAGE=opennsl-modules
3535
# modifieable for experiments or debugging m-a
3636
MA_DIR ?= /usr/share/modass
37-
KVERSION ?= 6.12.41+deb13-sonic-amd64
38-
KERNVERSION ?= 6.12.41+deb13-sonic
37+
KVER := $(word 1,$(subst -, ,$(KVERSION)))
38+
KVER_ARCH := $(KVER)-sonic-amd64
39+
KVER_COMMON := $(KVER)-common-sonic
3940

4041
# load generic variable handling
4142
-include $(MA_DIR)/include/generic.make
@@ -64,11 +65,11 @@ kdist_clean: clean
6465
dh_testdir
6566
dh_clean
6667
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 \
67-
KERNDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
68-
KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \
68+
KERNDIR=/usr/src/linux-headers-$(KVER_COMMON) \
69+
KERNEL_SRC=/usr/src/linux-headers-$(KVER_ARCH) \
6970
$(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean
7071
SDK=$(realpath .) BUILD_KNET_CB=1 \
71-
KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
72+
KDIR=/usr/src/linux-headers-$(KVER_COMMON) \
7273
$(MAKE) -C sdklt/ clean
7374
# rm -f driver/*.o driver/*.ko
7475
#
@@ -87,25 +88,25 @@ build-arch-stamp:
8788
dh_testdir
8889

8990
# create links
90-
cd /; sudo mkdir -p /lib/modules/$(KERNVERSION)-amd64
91-
cd /; sudo rm /lib/modules/$(KERNVERSION)-amd64/build
92-
cd /; sudo rm /lib/modules/$(KERNVERSION)-amd64/source
93-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-common/ /lib/modules/$(KERNVERSION)-amd64/source
94-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/ /lib/modules/$(KERNVERSION)-amd64/build
95-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/include/generated/ /usr/src/linux-headers-$(KERNVERSION)-common/include/generated
96-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/arch/x86/include/generated/ /usr/src/linux-headers-$(KERNVERSION)-common/arch/x86/include/generated
97-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/arch/x86/module.lds /usr/src/linux-headers-$(KERNVERSION)-common/arch/x86/module.lds
98-
cd /; sudo ln -s /usr/src/linux-headers-$(KERNVERSION)-amd64/include/config/ /usr/src/linux-headers-$(KERNVERSION)-common/include/config
99-
cd /; sudo cp /usr/src/linux-headers-$(KERNVERSION)-amd64/Module.symvers /usr/src/linux-headers-$(KERNVERSION)-common/Module.symvers
91+
cd /; sudo mkdir -p /lib/modules/$(KVER_ARCH)
92+
cd /; sudo rm /lib/modules/$(KVER_ARCH)/build
93+
cd /; sudo rm /lib/modules/$(KVER_ARCH)/source
94+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_COMMON)/ /lib/modules/$(KVER_ARCH)/source
95+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_ARCH)/ /lib/modules/$(KVER_ARCH)/build
96+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_ARCH)/include/generated/ /usr/src/linux-headers-$(KVER_COMMON)/include/generated
97+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_ARCH)/arch/x86/include/generated/ /usr/src/linux-headers-$(KVER_COMMON)/arch/x86/include/generated
98+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_ARCH)/arch/x86/module.lds /usr/src/linux-headers-$(KVER_COMMON)/arch/x86/module.lds
99+
cd /; sudo ln -s /usr/src/linux-headers-$(KVER_ARCH)/include/config/ /usr/src/linux-headers-$(KVER_COMMON)/include/config
100+
cd /; sudo cp /usr/src/linux-headers-$(KVER_ARCH)/Module.symvers /usr/src/linux-headers-$(KVER_COMMON)/Module.symvers
100101

101102
# Add here command to compile/build the package.
102103
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 \
103-
KERNDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
104-
KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \
104+
KERNDIR=/usr/src/linux-headers-$(KVER_COMMON) \
105+
KERNEL_SRC=/usr/src/linux-headers-$(KVER_ARCH) \
105106
$(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6
106107

107108
SDK=$(realpath .) BUILD_KNET_CB=1 \
108-
KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
109+
KDIR=/usr/src/linux-headers-$(KVER_COMMON) \
109110
$(MAKE) -C sdklt/ kmod
110111

111112
touch $@
@@ -132,12 +133,12 @@ clean:
132133

133134
# Add here commands to clean up after the build process.
134135
SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 \
135-
KERNDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
136-
KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \
136+
KERNDIR=/usr/src/linux-headers-$(KVER_COMMON) \
137+
KERNEL_SRC=/usr/src/linux-headers-$(KVER_ARCH) \
137138
$(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean
138139

139140
SDK=$(realpath .) BUILD_KNET_CB=1 \
140-
KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \
141+
KDIR=/usr/src/linux-headers-$(KVER_COMMON) \
141142
$(MAKE) -C sdklt/ clean
142143

143144
dh_clean

platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ CFGFLAGS += -DSAL_SPL_LOCK_ON_IRQ
3434
include ${SDK}/make/Makefile.linux-x86-generic-common-2_6
3535

3636
ifeq (,$(KFLAGS))
37-
KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -fno-pie -mcmodel=kernel -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign
37+
KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror=implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -fno-pie -mcmodel=kernel -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -g -Wdeclaration-after-statement -Wno-pointer-sign \
38+
-Wno-declaration-after-statement -Wno-missing-prototypes -Wno-array-bounds -fcf-protection
39+
3840
ifneq (1,$(USE_CLANG))
3941
KFLAGS += -funit-at-a-time -maccumulate-outgoing-args
4042
endif

platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ngbde_dmamem_kapi_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem)
9191
dmamem->baddr = baddr;
9292

9393
/* Write small signature for debug purposes */
94-
strlcpy((char *)vaddr, "DMA_KAPI", dmactrl->size);
94+
strscpy((char *)vaddr, "DMA_KAPI", dmactrl->size);
9595

9696
if (dma_debug) {
9797
printk("DMA: Allocated %d KB of KAPI memory at 0x%08lx\n",
@@ -138,7 +138,7 @@ ngbde_dmamem_pgmem_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem)
138138
}
139139

140140
/* Write small signature for debug purposes */
141-
strlcpy((char *)vaddr, "DMA_PGMEM", dmactrl->size);
141+
strscpy((char *)vaddr, "DMA_PGMEM", dmactrl->size);
142142

143143
if (dma_debug) {
144144
printk("DMA: Allocated %d KB of PGMEM memory at 0x%08lx\n",
@@ -177,7 +177,7 @@ ngbde_dmamem_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem)
177177
/* Always allow KAPI when CMA is available */
178178
kapi = 1;
179179
#else
180-
if (dmactrl->size <= (1 << (MAX_ORDER - 1 + PAGE_SHIFT))) {
180+
if (dmactrl->size <= (1 << (MAX_PAGE_ORDER - 1 + PAGE_SHIFT))) {
181181
kapi = 1;
182182
}
183183
#endif

platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ ngbde_intr_alloc(int kdev, unsigned int num_irq)
330330
}
331331

332332
/* Use new API if available (Linux 4.8 and newer) */
333-
irq_types = PCI_IRQ_LEGACY;
333+
irq_types = PCI_IRQ_INTX;
334334
if (sd->use_msi) {
335335
irq_types |= PCI_IRQ_MSI;
336336
if (sd->use_msi == NGBDE_MSI_T_MSIX) {

platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ iproc_cmicd_probe(struct platform_device *pldev)
115115
*
116116
* \retval 0 No errors
117117
*/
118-
static int
118+
static void
119119
iproc_cmicd_remove(struct platform_device *pldev)
120120
{
121-
return 0;
121+
return;
122122
}
123123

124124
/*! Matching compatible property with device tree. */

platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
******************************************************************************/
5656

5757
/*! Maximum size the kernel can allocate in a single allocation. */
58-
#define MEM_CHUNK_SIZE_MAX (1 << (MAX_ORDER - 1 + PAGE_SHIFT))
58+
#define MEM_CHUNK_SIZE_MAX (1 << (MAX_PAGE_ORDER - 1 + PAGE_SHIFT))
5959

6060
/*! Default block size we wil request from the kernel. */
6161
#define MEM_CHUNK_SIZE_DEFAULT (512 * ONE_KB)

platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ static inline void page_ref_dec(struct page *page)
139139
#define DMA_FORCE_CONTIGUOUS DMA_ATTR_FORCE_CONTIGUOUS
140140
#endif
141141

142-
#ifndef PCI_IRQ_LEGACY
142+
#ifndef PCI_IRQ_INTX
143143
/* Emulate new IRQ API if not available */
144-
#define PCI_IRQ_LEGACY (1 << 0)
144+
#define PCI_IRQ_INTX (1 << 0)
145145
#define PCI_IRQ_MSI (1 << 1)
146146
#define PCI_IRQ_MSIX (1 << 2)
147147
static inline int
@@ -154,7 +154,7 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
154154
return 1;
155155
}
156156
}
157-
if (flags & PCI_IRQ_LEGACY) {
157+
if (flags & PCI_IRQ_INTX) {
158158
return 1;
159159
}
160160
return 0;

platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ ngknet_filter_cb_register_by_name(ngknet_filter_cb_f filter_cb, const char *desc
315315
return -1;
316316
}
317317
fcb->cb = filter_cb;
318-
strlcpy(fcb->desc, desc, sizeof(fcb->desc));
318+
strscpy(fcb->desc, desc, sizeof(fcb->desc));
319319
list_add_tail(&fcb->list, &callback_ctrl.filter_cb_list);
320320

321321
/* Check if any existing filter matches the registered name */

platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,15 +1684,15 @@ static const struct net_device_ops ngknet_netdev_ops = {
16841684
static void
16851685
ngknet_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *drvinfo)
16861686
{
1687-
strlcpy(drvinfo->driver, "linux_ngknet", sizeof(drvinfo->driver));
1687+
strscpy(drvinfo->driver, "linux_ngknet", sizeof(drvinfo->driver));
16881688
snprintf(drvinfo->version, sizeof(drvinfo->version), "%d", NGKNET_IOC_VERSION);
1689-
strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
1690-
strlcpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info));
1689+
strscpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
1690+
strscpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info));
16911691
}
16921692

16931693
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
16941694
static int
1695-
ngknet_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info)
1695+
ngknet_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *info)
16961696
{
16971697
int rv;
16981698

@@ -1947,7 +1947,7 @@ ngknet_dev_info_get(int dn)
19471947
}
19481948

19491949
dev->dev_info.dev_no = dn;
1950-
strlcpy(dev->dev_info.type_str, drv_ops[dev->pdma_dev.dev_type]->drv_desc,
1950+
strscpy(dev->dev_info.type_str, drv_ops[dev->pdma_dev.dev_type]->drv_desc,
19511951
sizeof(dev->dev_info.type_str));
19521952
dev->dev_info.vdev = dev->vdev;
19531953
return SHR_E_NONE;
@@ -2552,7 +2552,7 @@ ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
25522552
DBG_CMD(("NGKNET_DEV_INIT\n"));
25532553
if (dev->flags & NGKNET_DEV_ACTIVE) {
25542554
DBG_CMD(("NGKNET_DEV_INIT, retrieve device configurations.\n"));
2555-
strlcpy(dev_cfg->name, pdev->name, sizeof(dev_cfg->name));
2555+
strscpy(dev_cfg->name, pdev->name, sizeof(dev_cfg->name));
25562556
dev_cfg->dev_id = pdev->dev_id;
25572557
dev_cfg->nb_grp = pdev->ctrl.nb_grp;
25582558
dev_cfg->bm_grp = pdev->ctrl.bm_grp;
@@ -2578,15 +2578,15 @@ ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
25782578
break;
25792579
}
25802580
memset(pdev, 0, sizeof(*pdev));
2581-
strlcpy(pdev->name, dev_cfg->name, sizeof(pdev->name));
2581+
strscpy(pdev->name, dev_cfg->name, sizeof(pdev->name));
25822582
pdev->dev_id = dev_cfg->dev_id;
25832583
for (dt = 0; dt < drv_num; dt++) {
25842584
if (!drv_ops[dt]) {
25852585
continue;
25862586
}
25872587
if (!strcasecmp(dev_cfg->type_str, drv_ops[dt]->drv_desc)) {
25882588
pdev->dev_type = dt;
2589-
strlcpy(dev->dev_info.var_str, dev_cfg->var_str,
2589+
strscpy(dev->dev_info.var_str, dev_cfg->var_str,
25902590
sizeof(dev->dev_info.var_str));
25912591
break;
25922592
}

platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
#if _SIMPLE_MEMORY_ALLOCATION_
9595
#include <linux/dma-mapping.h>
9696
#ifndef CONFIG_CMA
97-
#define DMA_MAX_ALLOC_SIZE (1 << (MAX_ORDER - 1 + PAGE_SHIFT)) /* Maximum size the kernel can allocate in one allocation */
97+
#define DMA_MAX_ALLOC_SIZE (1 << (MAX_PAGE_ORDER - 1 + PAGE_SHIFT)) /* Maximum size the kernel can allocate in one allocation */
9898
#endif /* !CONFIG_CMA */
9999
#endif /* _SIMPLE_MEMORY_ALLOCATION_ */
100100

@@ -139,7 +139,7 @@
139139
#endif
140140

141141
#ifndef KMALLOC_MAX_SIZE
142-
#define KMALLOC_MAX_SIZE (1UL << (MAX_ORDER - 1 + PAGE_SHIFT))
142+
#define KMALLOC_MAX_SIZE (1UL << (MAX_PAGE_ORDER - 1 + PAGE_SHIFT))
143143
#endif
144144

145145
/* Compatibility */

0 commit comments

Comments
 (0)