Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAC infra sysapi files #18646

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions src/sonic-pac/fpinfra/sysapi/sysapi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright 2024 Broadcom Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <string.h>
#include "pacinfra_common.h"
#include "product.h"
#include "resources.h"
#include "osapi.h"
#include "sysapi.h"
#include "defaultconfig.h"

static void * sysapiTimerTaskID = 0;

/*************************************
* Mbuf Queue declarations
*************************************/
void **pMbufQTop; /* top of queue */
void **pMbufQBot; /* bottom of queue */
void **MbufQHead;
void **MbufQTail;
uint32 MbufsFree;
uint32 MbufsRxUsed;
uint32 MbufsMaxFree;
void *pMbufPool;


/**************************************************************************
*
* @purpose Task that creates the application timer function
*
* @param none
*
* @returns none.
*
* @notes If the task is already created, just return.
*
* @end
*
*************************************************************************/
void sysapiTimerTaskStart(void)
{
if ( sysapiTimerTaskID != 0 )
{
return;
}
sysapiTimerTaskID = osapiTaskCreate( "osapiTimer",
(void *)osapiTimerHandler,
0,
NULLPTR,
DEFAULT_STACK_SIZE,
MEDIUM_TASK_PRIORITY,
DEFAULT_TASK_SLICE);

/* Wait for osapiTimer task to finish initialization.*/
if (osapiWaitForTaskInit( OSAPI_TIMER_TASK_SYNC, WAIT_FOREVER) != SUCCESS)
{
//SYSAPI_PRINTF(SYSAPI_LOGGING_ALWAYS, "In routine %s line %d, osapiWaitForTaskInit failed\n",
// __FUNCTION__, __LINE__);
//LOG_ERROR(0);
}
return;
}

/**************************************************************************
* @purpose Initialize the sysapi component
*
* @param none
*
* @returns SUCCESS
* @returns ERROR
*
* @notes
*
* @end
*
*************************************************************************/
RC_t sysapiSystemInit(void)
{
int32 i;
uint32 temp32;
uint32 phy_size = 0;
uint32 mtu_size = FD_NIM_DEFAULT_MTU_SIZE;

/* initialize system timers */
sysapiTimerTaskStart();

/* Reserve extra space for control overhead. */
phy_size += (sizeof(SYSAPI_NET_MBUF_HEADER_t) + NET_MBUF_START_OFFSET + 64);

temp32 = phy_size + mtu_size + SYSAPI_PKT_BUF_ALIGN_LEN;

pMbufPool = osapiMalloc ( SIM_COMPONENT_ID, MAX_NETWORK_BUFF_PER_BOX * ( temp32 ) );
if ( pMbufPool == NULLPTR )
return( ERROR);


/********************************************************
* Allocate the "mbuf" Queue. Each entry is a 32 bit ptr
*********************************************************/
pMbufQTop = ( void ** )osapiMalloc ( SIM_COMPONENT_ID, MAX_NETWORK_BUFF_PER_BOX * sizeof (void *));
if ( pMbufQTop == NULLPTR )
return( ERROR);

/***************************************************
* Initialize the "mbuf" Queue and counter.
****************************************************/
MbufQHead = pMbufQTop;
MbufQTail = pMbufQTop;
MbufsMaxFree = MAX_NETWORK_BUFF_PER_BOX;
MbufsFree = MbufsMaxFree;
MbufsRxUsed = 0;
memset(&mbuf_stats, 0, sizeof(mbuf_stats_t));

for ( i=0;i<( int32)MbufsFree;i++ )
{
*MbufQHead = ( void * ) ( ( uchar8 *)pMbufPool + i * ( temp32 ));
MbufQHead++;
}
pMbufQBot = --MbufQHead; /* set bottom of queue ptr */
MbufQHead = pMbufQTop; /* reset head ptr to top */


return( SUCCESS);
}
45 changes: 45 additions & 0 deletions src/sonic-pac/fpinfra/sysapi/sysapi_hpc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2024 Broadcom Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "pacinfra_common.h"

typedef struct
{
IANA_INTF_TYPE_t type;
PORT_SPEEDS_t defaultSpeed;
uint64 phyCapabilities; /* combination of all applicable PHY_CAPABILITIES_t */
/* CONNECTOR_TYPES_t connectorType;*/
fec_mode_t defaultFEC;
uint32 fecCapabilities; /* combination of all applicable FEC_CAPABILITY_t */
} SYSAPI_HPC_PORT_DESCRIPTOR_t;

/**************************************************************************
*
* @purpose Return the number of physical ports, given a slot number.
*
* @param slotNum slot number for requested card ID.
*
* @returns portCount Number of physical ports in slot number
*
* @notes
*
* @end
*
*************************************************************************/
uint32 sysapiHpcPhysPortsInSlotGet(int slotNum)
{
return 255; //needs to work on it
}
Loading
Loading