2c0f4e57d7
Why I did it XGS saibcm-modules 8.4 is needed. #14471 Work item tracking Microsoft ADO (number only): 24917414 How I did it Copy files from xgs SDK 8.4 repo and modify makefiles to build the image. Upgrade version to 8.4.0.2 in saibcm-modules.mk. How to verify it Build a private image and run full qualification with it: https://elastictest.org/scheduler/testplan/650419cb71f60aa92c456a2b
80 lines
2.0 KiB
C
80 lines
2.0 KiB
C
/*! \file ngbde_swdev.c
|
|
*
|
|
* <description>
|
|
*
|
|
*/
|
|
/*
|
|
* $Copyright: Copyright 2018-2022 Broadcom. All rights reserved.
|
|
* The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* A copy of the GNU General Public License version 2 (GPLv2) can
|
|
* be found in the LICENSES folder.$
|
|
*/
|
|
|
|
#include <ngbde.h>
|
|
|
|
/* Switch devices */
|
|
static struct ngbde_dev_s swdevs[NGBDE_NUM_SWDEV_MAX];
|
|
|
|
/* Number of probed switch devices */
|
|
static unsigned int num_swdev;
|
|
|
|
int
|
|
ngbde_swdev_add(struct ngbde_dev_s *nd)
|
|
{
|
|
unsigned int idx;
|
|
|
|
/* Look for existing slot */
|
|
for (idx = 0; idx < num_swdev; idx++) {
|
|
if (swdevs[idx].bus_no == nd->bus_no &&
|
|
swdevs[idx].slot_no == nd->slot_no) {
|
|
if (swdevs[idx].inactive) {
|
|
memcpy(&swdevs[idx], nd, sizeof(swdevs[0]));
|
|
return 0;
|
|
}
|
|
/* Active device in this slot already? */
|
|
printk(KERN_WARNING "%s: Device exists\n",
|
|
MOD_NAME);
|
|
return -EBUSY;
|
|
}
|
|
}
|
|
|
|
/* Add new device */
|
|
if (num_swdev >= NGBDE_NUM_SWDEV_MAX) {
|
|
return -ENOMEM;
|
|
}
|
|
memcpy(&swdevs[num_swdev], nd, sizeof(swdevs[0]));
|
|
++num_swdev;
|
|
return 0;
|
|
}
|
|
|
|
struct ngbde_dev_s *
|
|
ngbde_swdev_get(int kdev)
|
|
{
|
|
if ((unsigned int)kdev < num_swdev) {
|
|
return &swdevs[kdev];
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int
|
|
ngbde_swdev_get_all(struct ngbde_dev_s **nd, unsigned int *num_nd)
|
|
{
|
|
if (nd) {
|
|
*nd = swdevs;
|
|
}
|
|
if (num_nd) {
|
|
*num_nd = num_swdev;
|
|
}
|
|
return 0;
|
|
}
|