ADLINK aTCA-N700 User Manual

Page 1
ADLINK Switch Manager
API Programming Guide
Manual Revision: 1.00 Revision Date: August 28, 2013 Part Number: 50-1G026-1000
Page 2
Revision History
Rev Date Description
1.00 28/8/2013 Initial release
Switch Manager API Programming Guide
2
Page 3
Switch Manager API Programming Guide

Preface

Copyright 2013 ADLINK Technology, Inc.
This document contains proprietary information protected by copyright. All rights are reserved. No part of this manual may be reproduced by any mechanical, electronic, or other means in any form without prior written permission of the manufacturer.
Disclaimer The information in this document is subject to change without prior notice in order to improve reliability , design, and fun ction and does not represent a commitm ent on the p art of the manufacturer. In no event will the manufacturer be liable for direct, indirect, special, incidental, or consequential damages arising out of the use or inability to use the product or documentation, even if advised of the possibility of such damages.
Environmental Responsibility
ADLINK is committed to fulfill its social responsibility to global environmental preservation through compliance with the European Union's Restriction of Hazardous Substances (RoHS) directive and Waste Electrical and Electronic Equipment (WEEE) directive. Environmental protection is a top priority for ADLINK. We have enforced measures to ensure that our products, manufacturing processes, components, and raw materials have as little impact on the environment as possible. When products are at their end of life, our customers are encouraged to dispose of them in accordance with the product disposal and/or recovery programs prescribed by their nation or company.
Trademarks
Product names mentioned herein are used for identification purposes only and may be trademarks and/or registered trademarks of their respective companies.
3
Page 4
Switch Manager API Programming Guide
Table of Contents
Revision History.................................................................................................................... 2
Preface................................................................................................................................... 3
Table of Contents.................................................................................................................. 4
List of Figures.......................................................................................................................9
List of Tables.............................................................................Error! Bookmark not defined.
Introduction......................................................................................................................... 11
Architecture Overview........................................................................................................11
Deliverables......................................................................................................................... 12
Section 1: Base...................................................................................................................12
Enum Type........................................................................................................................ 12
status_t..........................................................................................................................12
Functions........................................................................................................................... 13
adlink_switch_chip_init ()...............................................................................................13
adlink_config_write ().....................................................................................................13
Section 2: VLAN.................................................................................................................. 14
Macro Definitions............................................................................................................... 14
MAX_VLAN_MAC_CNT ................................................................................................ 14
Enum Type........................................................................................................................ 14
adlink_vlan_tag_mode_t................................................................................................14
Data Structure...................................................................................................................14
adlink_vlan_info_t.......................................................................................................... 14
adlink_vlan_mac_t......................................................................................................... 15
Functions........................................................................................................................... 15
adlink_vlan_info_get ()................................................................................................... 15
adlink_vlan_admin_status_set ()...................................................................................16
adlink_vlan_create () ..................................................................................................... 16
adlink_vlan_destroy ().................................................................................................... 16
adlink_vlan_member_add ()..........................................................................................17
4
Page 5
Switch Manager API Programming Guide
adlink_vlan_member_del () ........................................................................................... 17
adlink_port_default_vlan_set ()...................................................................................... 17
adlink_mac_based_vlan_add ().....................................................................................18
adlink_mac_based_vlan_del ()...................................................................................... 18
adlink_mac_based_vlan_get ()......................................................................................18
Section 3: Port..................................................................................................................... 19
Macro Definitions............................................................................................................... 19
MIN_FABRIC_PORT_ID ............................................................................................... 19
MAX_FABRIC_PORT_ID..............................................................................................19
MIN_BASE_PORT_ID................................................................................................... 19
MAX_BASE_PORT_ID..................................................................................................19
FABRIC_PORT_NUM ................................................................................................... 19
BASE_PORT_NUM....................................................................................................... 19
SWITCH_PORT_CPU................................................................................................... 19
FRONT_PANEL_XE_START........................................................................................ 19
FRONT_PANEL_XE_END............................................................................................ 19
TAPNAMSIZ..................................................................................................................20
Enum Type........................................................................................................................ 20
port_duplex_t................................................................................................................. 20
port_speed_t..................................................................................................................20
port_link_status_t........................................................................................................... 20
port_stp_state_t............................................................................................................. 21
port_vlan_filter_mode_mask_t....................................................................................... 21
port_rate_limit_mask_t .................................................................................................. 21
nic_config_mask_t......................................................................................................... 21
Data Structure...................................................................................................................22
adlink_port_info_t .......................................................................................................... 22
adlink_portstat_t ............................................................................................................ 22
adlink_set_port_status_cmd_t....................................................................................... 23
adl_nic_config_set_cmd_t.............................................................................................23
5
Page 6
Switch Manager API Programming Guide
adl_nic_config_info_t..................................................................................................... 23
adl_nic_config_get_cmd_t............................................................................................. 24
Functions........................................................................................................................... 24
adlink_port_info_get ()................................................................................................... 24
adlink_port_status_set () ............................................................................................... 24
adlink_port_filter_mac_add ()........................................................................................25
adlink_port_filter_mac_del () ......................................................................................... 25
adlink_port_statistic_get ().............................................................................................25
adlink_port_statistic_clear ().......................................................................................... 25
adlink_nic_config_set ()................................................................................................. 26
adlink_nic_config_get()..................................................................................................26
adlink_port_pipe_get ().................................................................................................. 26
adlink_port_pipe_set()...................................................................................................26
adlink_port_pipe_clear()................................................................................................26
Section 4: Trunk..................................................................................................................27
Macro Definitions............................................................................................................... 27
MIN_TRUNK_ID............................................................................................................27
MAX_TRUNK_ID........................................................................................................... 27
MAX_TRUNK_MEMBER...............................................................................................27
Enum Type........................................................................................................................ 27
adlink_trunk_psc_t.........................................................................................................27
Data Structure...................................................................................................................28
adlink_trunk_monitor_t .................................................................................................. 28
Functions........................................................................................................................... 28
adlink_trunk_member_add ().........................................................................................28
adlink_trunk_member_del ().......................................................................................... 28
adlink_trunk_clear ()......................................................................................................29
adlink_trunk_mode_set ()..............................................................................................29
adlink_trunk_info_get ().................................................................................................29
adlink_trunk_monitor_add ().......................................................................................... 30
6
Page 7
Switch Manager API Programming Guide
adlink_trunk_monitor_del ()...........................................................................................30
adlink_trunk_monitor_get ()........................................................................................... 30
Section 5: LAYER-2 ............................................................................................................ 31
Macro Definitions............................................................................................................... 31
MAC_SIZE.....................................................................................................................31
ADLINK_L2_xxx ............................................................................................................ 31
Enum Type........................................................................................................................ 31
Data Structure...................................................................................................................31
adlink_mac_entry_t........................................................................................................ 31
Functions........................................................................................................................... 32
adlink_mac_entry_add ()...............................................................................................32
adlink_mac_entry_del () ................................................................................................ 32
adlink_mac_table_clear ().............................................................................................. 32
adlink_mac_table_dump () ............................................................................................ 32
Section 6: ACL .................................................................................................................... 33
Macro Definitions............................................................................................................... 33
MAX_QUALIFIER_NUM................................................................................................33
Enum Type........................................................................................................................ 33
adlink_qualifier_type_t................................................................................................... 33
adlink_action_type_t...................................................................................................... 34
Data Structure...................................................................................................................34
adlink_acl_data_t...........................................................................................................34
adlink_acl_qualifier_info_t ............................................................................................. 35
adlink_acl_action_info_t ................................................................................................ 35
adlink_acl_rule_info_t.................................................................................................... 36
Functionsadlink_acl_rule_add ()....................................................................................36
adlink_acl_rule_delete ()................................................................................................ 36
adlink_acl_rule_clear ().................................................................................................. 37
adlink_acl_rule_get () .................................................................................................... 37
Section 7: Static Route.......................................................................................................38
7
Page 8
Switch Manager API Programming Guide
Macro Definitions............................................................................................................... 38
MAX_ROUTE_ENTRY_ONE_TIME_GET .................................................................... 38
Enum Type........................................................................................................................ 38
Data Structure...................................................................................................................38
adlink_route_info_t ........................................................................................................ 38
Functions........................................................................................................................... 39
adlink_route_add ()........................................................................................................39
adlink_route_delete ().................................................................................................... 39
adlink_route_table_clear ()............................................................................................39
adlink_route_table_dump ()........................................................................................... 40
Getting Service.................................................................................................................... 41
8
Page 9
Switch Manager API Programming Guide

List of Figures

Figure 1Hardware architecture for programming..........................................................11
9
Page 10
Switch Manager API Programming Guide

List of Tables

Table 1- 1, Return Code Description...............................................................................13
Table 6- 1, Qualifier Type Description............................................................................. 34
Table 6- 2, Action Type Description................................................................................. 34
Table 6- 3, Data Descriptions For Different Qualifier Types............................................ 35
Table 6- 4, Data Descriptions for Different Action Types.................................................36
10
Page 11
Switch Manager API Programming Guide
Introduction
This guide describes the how to program ADLINK Switch Management APIs on ADLINK's switch blades, such as the aTCA-3420, aTCA-N700, and aTCA-3710. Firstly, we will introduce the overall software architecture for programming. Secondly, we define the released deliverables, including header file, static library, binary files, example project and readme files. Finally, detailed API definitions and references will be provided to allow customers to easily program their own APIs.
Architecture Overview
All the APIs listed in this document are programmed using the following hardware architecture, shown in Figure 1. In this figure, the client is running on a standalone server. However, it also can run on the LMP on the switch blade.
Switch Manager
API Library
runs on client
Controller
Figure 1Hardware architecture for programming
The ADLINK Switch Manager implements the network connections between server and client so that customers do not have to worry about the connections between them. Provided are the client API libraries, header files and relevant documentation for easy programming.
Ethernet
Switch Manager
core service runs on
blade server with
switch chip
Blade Server
11
Page 12
Switch Manager API Programming Guide
Deliverables
The ADLINK Switch Manager Library package (adSwitchLib-x.x.x.tar.gz) provides the following software components
Include: Header files of the ADLINK Switch Manager library Lib: Static library including the API functions listed in this document Bin: Binary files for controlling the switch system Example: ReadMe: The release notes for different library revisions
Application demo to show usage of the APIs provided

Section 1: Base

This section describes the macro, enum, struct and function for fundamentals. They are defined in the header file “adlink_api_base.h”.

Enum Type

status_t
typedef enum status { ADLINK_E_NONE = 0, /*no error*/ ADLINK_E_PARA = -1, /*parameter error*/ ADLINK_E_RESOURCE = -2, /*no available resource*/ ADLINK_E_EXIST = -3, /*item already exists*/ ADLINK_E_FIND = -4, /*item not found*/ ADLINK_E_SOCKET = -5, /*socket error*/ ADLINK_E_MALLOC = -6, /* mem allocation failed*/ ADLINK_E_OPEN = -7, /* open/fopen failed*/ ADLINK_E_OTHER = -8, /* Error other than above*/ //... ADLINK_E_SERVER_BASE = -128,/*base error code for server returned*/ }status_t;
This enum describes the return codes of the APIs. They are defined in “adlink_api_base.h”. Table 1-1 shows the meaning of each error code.
12
Page 13
Switch Manager API Programming Guide
Table 1- 1, Return Code Description
Return Code Description ADLINK_E_NONE API run successfully ADLINK_E_PARA Parameter related error ADLINK_E_RESOURCE Table item overflow ADLINK_E_EXIST Table item already existing ADLINK_E_FIND Table item non-existentent ADLINK_E_SOCKET Error occurs when connecting to BCM server ADLINK_E_MALLOC Error occurs when memory allocation ADLINK_E_OPEN Error occurs when open/fopen a handle ADLINK_E_OTHER Other error ADLINK_E_SERVER_BASE For a meaningful error code form server, we return it with
this value added. So, if the returned code is less than this value, we can subtract this value and get the real return value from server. This is useful for debugging.

Functions

adlink_switch_chip_init ()
PROTOTYPE
int adlink_switch_chip_init(UINT32 server_ip)
DESCRIPTION
This function is used to init the switch chip.
PARAMETERS server_ip [IN] IP address of the server
RETURN See the description of status_t above.
adlink_config_write ()
PROTOTYPE
int adlink_config_write()
DESCRIPTION
This function is used to write the current configuration into file. After the function is called successfully, the configuration will still be in effect after the system reboots.
13
Page 14
Switch Manager API Programming Guide
PARAMETERS
None
RETURN See the description of status_t above.

Section 2: VLAN

This section describes the macro, enum, struct and function for VLAN. They are defined in the header file “adlink_api_vlan.h”.

Macro Definitions

MAX_VLAN_MAC_CNT

Maximum entry count of MAC based VLAN.

Enum Type

adlink_vlan_tag_mode_t

typedef enum adlink_vlan_tag_mode_e{ VLAN_MODE_UNTAGGED = 0, VLAN_MODE_TAGGED = 1, } adlink_vlan_tag_mode_t; Define the codes of port mode in VLAN.

Data Structure

adlink_vlan_info_t
typedef struct adlink_vlan_info_s { UINT8 enable; /*admin status*/
14
Page 15
Switch Manager API Programming Guide
UINT8 created; /*whether it is created on hardware*/ UINT8 rsv1[2]; /*for align purpose*/ UINT32 pbmp; /*port bitmap in this vlan*/ UINT32 untag_pbmp; /*port bitmap of untagged ports*/ UINT32 pvid_pbmp; /*port bitmap take VID as default vlan*/ char name[MAX_VLAN_NAME_SIZE]; /*vlan name. 31 characters at maxmium*/ }adlink_vlan_info_t; Define the entry format of port based VLAN table.
adlink_vlan_mac_t
typedef struct adlink_vlan_mac_s { UINT8 valid; /*in using or not. VALID/INVALID*/ UINT8 cos; /*priority value. 0-7*/ UINT8 mac[MAC_SIZE]; /*MAC address*/ UINT16 vid; /*VLAN id. 1-4094*/ UINT8 rsv[2]; /*reserved*/ }adlink_vlan_mac_t; Define the entry format of MAC based VLAN table.

Functions

adlink_vlan_info_get ()
PROTOTYPE
status_t adlink_vlan_info_get (int vlan, adlink_vlan_info_t *info);
DESCRIPTION
This function is used to get port based VLAN information.
PARAMETERS vlan [IN] The VLAN ID to be configed; info [OUT] VLAN information;
RETURN
See the description of status_t in Section 1.
15
Page 16
Switch Manager API Programming Guide
adlink_vlan_admin_status_set ()
PROTOTYPE
status_t adlink_vlan_admin_status_set (int vlan, int status);
DESCRIPTION
This function is used to switch admin status of a VLAN. VLAN can be configured but not used. To use created VLANs, set them ENABLE.
PARAMETERS vlan [IN] The VLAN ID to be configured; status [IN] Admin status. Use ‘ENABLE’ or ‘DISABLE’;
RETURN See the description of status_t in Section 1.
adlink_vlan_create ()
PROTOTYPE
status_t adlink_vlan_create (int vlan, char*name);
DESCRIPTION
This function is used to create a new VLAN.
PARAMETERS vlan [IN] The VLAN ID to be created; name [IN] Description for new created VLAN;
RETURN See the description of status_t in Section 1.
adlink_vlan_destroy ()
PROTOTYPE
status_t adlink_vlan_destroy (int vlan);
DESCRIPTION
This function is used to destroy an existing VLAN.
16
Page 17
Switch Manager API Programming Guide
PARAMETERS vlan [IN] The VLAN ID to be destroyed;
RETURN See the description of status_t in Section 1.
adlink_vlan_member_add ()
adlink_vlan_member_del ()
PROTOTYPE
status_t adlink_vlan_member_add (int vlan, UINT32 port, UINT32 mode); status_t adlink_vlan_member_del (int vlan, UINT32 port);
DESCRIPTION
These two functions are used to add port into or remove port from a VLAN.
PARAMETERS vlan [IN] The VLAN ID in which port member is configured. port [IN] Port ID to be added/removed. mode [IN] Port is tagged or untagged in the VLAN. Use ‘VLAN_MODE_TAGGED’ or
‘VLAN_MODE_UNTAGGED’
RETURN See the description of status_t in Section 1.
adlink_port_default_vlan_set ()
PPROTOTYE
status_t adlink_port_default_vlan_set (int vlan, UINT32 port);
DESCRIPTION
This function is used to assign a port’s default VLAN tag for untagged packets.
PARAMETERS vlan [IN] The default VLAN ID of a port; port [IN] The port ID which will be assigned a default VLAN tag;
RETURN
17
Page 18
Switch Manager API Programming Guide
See the description of status_t in Section 1.
adlink_mac_based_vlan_add ()
adlink_mac_based_vlan_del ()
adlink_mac_based_vlan_get ()
PROTOTYPE
status_t adlink_mac_based_vlan_add (int vlan, UINT8 *mac, UINT8 cos); status_t adlink_mac_based_vlan_del (UINT8 *mac); status_t adlink_mac_based_vlan_get (UINT8 *mac, UINT16 *vlan, UINT8 *cos);
DESCRIPTION
These functions are used to configure MAC base VLAN. MAC address can be associated with a VLAN id.
PARAMETERS vlan [IN] The VLAN ID which will be assigned to a specified MAC address; mac [IN] A pointer points to specified MAC address; cos [IN] Default COS value which will be filled in VLAN tag;
RETURN
See the description of status_t in Section 1.
18
Page 19
Switch Manager API Programming Guide
Section 3: Port
This section describes the macro, enum, struct and function for port. They are defined in the head file “adlink_api_port.h”.

Macro Definitions

MIN_FABRIC_PORT_ID

MAX_FABRIC_PORT_ID

MIN_BASE_PORT_ID

MAX_BASE_PORT_ID

Define the port index value range of fabric and base switch chips.

FABRIC_PORT_NUM

BASE_PORT_NUM

Total port count of fabric and base switch chip.

SWITCH_PORT_CPU

FRONT_PANEL_XE_START

FRONT_PANEL_XE_END

Define the index value of some specific ports.
19
Page 20

TAPNAMSIZ

Define the maximum length of a NIC device name.

Enum Type

port_duplex_t
typedef enum port_duplex_e{ PORT_DUPLEX_FULL = 0, PORT_DUPLEX_HALF = 1, } port_duplex_t; Define the codes of port duplex mode.
Switch Manager API Programming Guide
port_speed_t
typedef enum port_speed_e{ PORT_SPEED_10M = 10, PORT_SPEED_100M = 100, PORT_SPEED_1G = 1000, PORT_SPEED_10G = 10000, } port_speed_t; Define the codes of port speed mode.
port_link_status_t
typedef enum port_link_status_e{ /*Heritage*/ PORT_LINK_STATUS_DOWN = 0, PORT_LINK_STATUS_UP = 1, PORT_LINK_STATUS_FAILED = 2, PORT_LINK_STATUS_REMOTE_FAULT = 3, } port_link_status_t; Define the codes of port physical link status.
20
Page 21
port_stp_state_t
typedef enum port_stp_state_e { /*Heritage */ PORT_STP_DISABLE = 0, /* Disabled. */ PORT_STP_BLOCK = 1, /* BPDUs/no learns. */ PORT_STP_LISTEN = 2, /* BPDUs/no learns. */ PORT_STP_LEARN = 3, /* BPDUs/learns. */ PORT_STP_FORWARD = 4, /* Normal operation. */ PORT_STP_COUNT = 5 } port_stp_state_t; Define the codes of port status for Spanning Tree Protocol.
port_vlan_filter_mode_mask_t
Switch Manager API Programming Guide
typedef enum port_vlan_filter_mode_mask_e { /*Heritage*/ PORT_VLAN_FILTER_INGRESS = 0x00000001, PORT_VLAN_FILTER_EGRESS = 0x00000002, } port_vlan_filter_mode_mask_t; Define the codes of VLAN filter mode in port attribute.
port_rate_limit_mask_t
typedef enum port_rate_limit_mask_e { /*Heritage*/ PORT_RATE_DLF = 0x01, PORT_RATE_MCAST = 0x02, PORT_RATE_BCAST = 0x04, PORT_RATE_UCAST = 0x08, } port_rate_limit_mask_t; Define the codes of rate limit type mask in port attribute.
nic_config_mask_t
typedef enum nic_config_mask { NIC_CONFIG_IP_MASK = 1, /*Set this bit to flag IP&MASK operation*/ NIC_CONFIG_STATUS = 2, /*Set this bit to flag NIC running status operation*/ }nic_config_mask_t; Define the codes of NIC operation.
21
Page 22

Data Structure

adlink_port_info_t
typedef struct adlink_port_info_s { int enable; int linkstatus; int autoneg; int speed; int duplex; UINT32 vlanfilter; int untagged_priority; UINT16 untagged_vlan; int stp_state; int pfm; /*port filter mode for multicast*/ int loopback; int pause_tx; int pause_rx; int encap_mode; int mcast_limit; int mcast_limit_enable; int bcast_limit; int bcast_limit_enable; int dlfbc_limit; int dlfbc_limit_enable; int frame_max; UINT32 fault; /*link fault reason*/ }adlink_port_info_t; Define the entry format of the port attribute table.
Switch Manager API Programming Guide
adlink_portstat_t
typedef struct adlink_portstat_s { UINT32 rx_byte_num; UINT32 rx_byte_rate; UINT32 rx_pkt_num;
22
Page 23
Switch Manager API Programming Guide
UINT32 rx_pkt_rate; UINT32 tx_byte_num; UINT32 tx_byte_rate; UINT32 tx_pkt_num; UINT32 tx_pkt_rate; }adlink_portstat_t; Define the entry format of the port statistic table.
adlink_set_port_status_cmd_t
typedef struct adlink_set_port_status_cmd { UINT32 port; /*port ID*/ UINT32 flag; /*PORT_ATTR_xxx in port_attribute_t*/ int status; /*ENABLE/DISABLE*/ int autoneg_mode; /*ENABLE/DISABLE*/ int duplex_mode; /*PORT_DUPLEX_xxx in port_duplex_t*/ int speed_mode; /*PORT_SPEED_xxx in port_speed_t*/ int pvid; /*default 802.1Q vid for untagged packets*/ int cos; /*default 802.1Q cos for untagged packets*/ int mtu; /*max data transmission unit*/ } adlink_set_port_status_cmd_t; Define the format of parameters used to set port attributes.
adl_nic_config_set_cmd_t
typedef struct adl_nic_config_set_cmd { char if_name[TAPNAMSIZ]; UINT32 config_mask; //nic_config_mask_t UINT32 ip; UINT32 netmask; UINT32 status; //0 down, 1 up }adl_nic_config_set_cmd_t; Define the format of parameters used to set NIC configuration.
adl_nic_config_info_t
typedef struct adl_nic_config_info { UINT32 ip;
23
Page 24
UINT32 mask; UINT32 status; }adl_nic_config_info_t; Define the format of retrieved NIC info.
adl_nic_config_get_cmd_t
typedef struct adl_nic_config_get_cmd { char if_name[TAPNAMSIZ]; }adl_nic_config_get_cmd_t; Define the format of the get NIC info command parameter.

Functions

Switch Manager API Programming Guide
adlink_port_info_get ()
PROTOTYPE
status_t adlink_port_info_get (UINT32 port, adlink_port_info_t *info);
DESCRIPTION
This function is used to get port information in an integrated data structure.
PARAMETERS port [IN] The port id; info [OUT] Port attributes will be filled in this structure;
RETURN See the description of status_t in Section 1.
adlink_port_status_set ()
PROTOTYPE
status_t adlink_port_status_set (adlink_set_port_status_cmd_t *cmd);
DESCRIPTION
This function is used to set various port attributes, including administrative status, auto-negotiation mode, duplex mode, speed, default vid, default cos and MTU.
24
Page 25
Switch Manager API Programming Guide
PARAMETERS cmd [IN] Port attributes to be set;
RETURN See the description of status_t in Section 1.

adlink_port_filter_mac_add ()

adlink_port_filter_mac_del ()
PROTOTYPE
status_t adlink_port_filter_mac_add (adlink_mac_entry_t *entry); status_t adlink_port_filter_mac_del (adlink_mac_entry_t *entry);
DESCRIPTION
These functions are used to add and delete MAC filter entries. MAC filters will filter ingress frames with specific source/destination MAC addresses on specific ports.
PARAMETERS entry [IN] The MAC entry to be filtered;
RETURN See the description of status_t in Section 1.

adlink_port_statistic_get ()

adlink_port_statistic_clear ()
PROTOTYPE
status_t adlink_port_statistic_get (UINT32 port, adlink_portstat_t *stat); status_t adlink_port_statistic_clear (UINT32 port);
DESCRIPTION
The function ‘get’ is used to get statistics of a port, including count and rate in both byte unit and packet unit. The function ‘clear’ is used to reset all counters.
PARAMETERS port [IN] The port id; stat [OUT] Statistics data will be filled in this structure;
25
Page 26
Switch Manager API Programming Guide
RETURN See the description of status_t in Section 1.
adlink_nic_config_set ()
adlink_nic_config_get()
PROTOTYPE
status_t adlink_nic_config_set(adl_nic_config_set_cmd_t *cmd); status_t adlink_nic_config_get(adl_nic_config_get_cmd_t *cmd, adl_nic_config_info_t *info);
DESCRIPTION
The function ‘get’ is used to get configuration of a NIC, including running status and IP address. The function ‘set’ is used to configure a NIC.
PARAMETERS cmd [IN] NIC name and operation code; info [OUT] NIC information;
RETURN See the description of status_t in Section 1.
adlink_port_pipe_get ()
adlink_port_pipe_set()
adlink_port_pipe_clear()
PROTOTYPE
status_t adlink_port_pipe_set(UINT32 src_port,UINT32 dst_port); status_t adlink_port_pipe_clear(UINT32 src_port); status_t adlink_port_pipe_get(UINT32 src_port,UINT32 *dst_port);
DESCRIPTION
These functions are used to pipe a specific port to another one. “pipe” will directly deliver ingress traffic on a specific port to another one.
26
Page 27
Switch Manager API Programming Guide
PARAMETERS src_port [IN] Ingress port; dst_port [IN|OUT] Destination port traffic will be delivered to;
RETURN See the description of status_t in Section 1.
Section 4: Trunk
This section describes the macro, enum, struct and function for trunk. They are defined in the header file “adlink_api_trunk.h”.

Macro Definitions

MIN_TRUNK_ID

MAX_TRUNK_ID

MAX_TRUNK_MEMBER

Trunk group index range and member count limit of a group.

Enum Type

adlink_trunk_psc_t
typedef enum adlink_trunk_psc_e { PSC_ZERO = 0, PSC_SA = 1, PSC_DA = 2, PSC_SA_DA = 3, PSC_SIP = 4, PSC_DIP = 5, PSC_SIP_DIP = 6, }adlink_trunk_psc_t; Define the codes of trunk port selection criteria. Packets will be dispatched to different ports based on the criteria.
27
Page 28
Switch Manager API Programming Guide

Data Structure

adlink_trunk_monitor_t
typedef struct tm_port_node_s { UINT32 id; /*port number. start at 1 */ UINT32 status; /*link status. 0-link down/1-link up */ }tm_port_node_t;
typedef struct tm_group_node_s { UINT32 valid; /*indicate whether group is in monitor. 0-invalid/1-valid */ UINT32 cnt; /*port count in a trunk group*/ tm_port_node_t item[MAX_TRUNK_MEMBER]; /*port info*/ }tm_group_node_t;
typedef struct adlink_trunk_monitor_s { tm_group_node_t group[MAX_TRUNK_ID]; }adlink_trunk_monitor_t; Define the entry format of port attribute table.

Functions

adlink_trunk_member_add ()

adlink_trunk_member_del ()
PROTOTYPE
status_t adlink_trunk_member_add (int trunk_id, UINT32 member_bmp); status_t adlink_trunk_member_del (int trunk_id, UINT32 member_bmp);
DESCRIPTION
These functions are used to change trunk group member ports.
PARAMETERS trunk_id [IN] Trunk group id; Start from ‘1’; member_bmp [IN] Member ports in bitmap;
28
Page 29
RETURN See the description of status_t in Section 1.
adlink_trunk_clear ()
PROTOTYPE
status_t adlink_trunk_clear ();
DESCRIPTION
This function is used to destroy all created trunk groups.
PARAMETERS
None
RETURN
See the description of status_t in Section 1.
Switch Manager API Programming Guide
adlink_trunk_mode_set ()
PROTOTYPE
status_t adlink_trunk_mode_set (int trunk_id, int mode);
DESCRIPTION
This function is used to change trunk group port selection criteria.
PARAMETERS trunk_id [IN] Trunk group id; Start from ‘1’; mode [IN] Trunk group PSC mode. PSC_XXX;
RETURN See the description of status_t in Section 1.
adlink_trunk_info_get ()
PROTOTYPE
status_t adlink_trunk_info_get (int tid, adlink_trunk_db_t *info);
DESCRIPTION
29
Page 30
This function is used to get trunk group information.
PARAMETERS tid [IN] Trunk group id; Start from ‘1’; info [OUT] Trunk group information;
RETURN See the description of status_t in Section 1.

adlink_trunk_monitor_add ()

adlink_trunk_monitor_del ()

Switch Manager API Programming Guide
adlink_trunk_monitor_get ()
PROTOTYPE
status_t adlink_trunk_monitor_add (int group_index); status_t adlink_trunk_monitor_del (int group_index); status_t adlink_trunk_monitor_get (adlink_trunk_monitor_t *tm);
DESCRIPTION
These functions are used to control trunk groups to be monitored or not. For groups in monitor, member ports with a link failure will be removed from group.
PARAMETERS group_index [IN] Trunk group id; Start from ‘1’; tm [OUT] Trunk group status in monitor;
RETURN
See the description of status_t in Section 1.
30
Page 31
Switch Manager API Programming Guide
Section 5: Layer-2
This section describes the macro, enum, struct and function for Layer-2. They are defined in the header file “adlink_api_l2.h”.

Macro Definitions

MAC_SIZE

MAC addresses data size in bytes.

ADLINK_L2_xxx

L2 entry flag masks. Flags are special attributes of the MAC entry. For details, please refer to the definitions in “adlink_api_l2. h”

Enum Type

None

Data Structure

adlink_mac_entry_t
typedef struct adlink_mac_entry_s { UINT32 port; /*port ID associated with the entry, start from 1*/ UINT16 vid; /*vlan id*/ UINT8 rsv0[2]; /*reserved*/ UINT32 flag; /*entry flag, ADLINK_L2_XXX*/ UINT8 mac[MAC_SIZE]; /*mac address*/ UINT8 rsv1[2]; /*reserved*/ } adlink_mac_entry_t; Define the entry format of the MAC table.
31
Page 32
Switch Manager API Programming Guide

Functions

adlink_mac_entry_add ()

adlink_mac_entry_del ()

adlink_mac_table_clear ()
PROTOTYPE
status_t adlink_mac_entry_add (adlink_mac_entry_t *entry); status_t adlink_mac_entry_del (adlink_mac_entry_t *entry); status_t adlink_mac_table_clear ();
DESCRIPTION
These functions are used to change the MAC address table. Add/delete an item or clear all items.
PARAMETERS entry [IN] Entry that will be added or deleted;
RETURN See the description of status_t in Section 1.
adlink_mac_table_dump ()
PROTOTYPE
status_t adlink_mac_table_dump (proxy_index_t *start_index, proxy_mac_dump_t *list);
DESCRIPTION
This function is used to dump the entire MAC address table.
PARAMETERS start_index [IN] Start index of MAC address table; list [OUT] Retrieved MAC entries;
RETURN
See the description of status_t in Section 1.
32
Page 33
Switch Manager API Programming Guide
Section 6: ACL
This section describes the macro, enum, struct and function for ACL. They are defined in the header file “adlink_api_acl.h”.

Macro Definitions

MAX_QUALIFIER_NUM

The ACL supports multiple qualifiers. This macro defines the maximum qualifier number allowed.

Enum Type

adlink_qualifier_type_t
typedef enum adlink_qualifier_type { INPORTS = 1, //port bit mask,data32 SRCIP, //data32 DSTIP, //data32 IPPROTOCOL, //data8 L4SRCPORT, //data16 L4DSTPORT, //data16 SRCMAC, //data48 DSTMAC, //data48 SRCTRUNK, //data16 ETHERTYPE, //data16 INNERVLAN, //data16 OUTERVLAN, //data16 } adlink_qualifier_type_t;
33
Page 34
Switch Manager API Programming Guide
Table 6- 1, Qualifier Type Description
Qualifier Type Description INPORTS Filter for the port ID a packet comes from SRCIP Filter for source IP address of a packet DSTIP Filter for destination IP address of a packet IPPROTOCOL Filter for IP protocol (such as 0x06 for TCP) of a packet L4SRCPORT Filter for L4 source port of a packet L4DSTPORT Filter for L4 destination port of a packet SRCMAC Filter for source MAC address of a packet DSTMAC Filter for destination MAC address of a packet SRCTRUNK Filter for the trunk ID a packet comes from ETHERTYPE Filter for Ethernet type (such as 0x0806 for ARP) of a packet INNERVLAN Filter for the inner VLAN ID of a packet OUTERVLAN Filter for the outer VLAN ID of a packet
adlink_action_type_t
typedef enum adlink_action_type { REDIRECTPORT = 1, //port bit mask, data32, only one port is permitted REDIRECTTRUNK, //trunk id, data16 DROP, //no param } adlink_action_type_t;
Table 6- 2, Action Type Description
Action Type Description REDIRECTPORT Redirect the packet to a port (cpu0, xe0, xe1, xe2…). REDIRECTTRUNK Redirect the packet to a trunk DROP Drop the packet

Data Structure

adlink_acl_data_t
typedef struct adlink_acl_data { UINT8 data128[16]; //data128 use, such as ipv6 addr UINT64 data64; //data64 use UINT8 data48[6]; //data48 use, such as mac addr UINT32 data32; //data32 use, such as ip addr
34
Page 35
Switch Manager API Programming Guide
UINT16 data16; //data16 use, such as l4port UINT8 data8; //data8 use, such as ip protocol } adlink_acl_data_t; For different qualifiers and actions, there are different data lengths. For example, an IP address is 32 bits long, a MAC address is 48 bits long, and an L4 port ID is 16 bits long. This data structure was defined in order to accommodate these different situations. Careful attention must be paid to refer to the appropriate member according to the actual situation. The appropriate members for existing qualifiers and actions are listed in the Tables 6-3 and 6-4.
adlink_acl_qualifier_info_t
typedef struct adlink_acl_qualifier_info { adlink_qualifier_type_t type;//qualifier type adlink_acl_data_t data;//union, use the correct member for different types adlink_acl_data_t mask;//union, use the correct member for different types } adlink_acl_qualifier_info_t;
Table 6- 3, Data Descriptions For Different Qualifier Types
Qualifier Type Data mask INPORTS data32 (port bit maps,cpu0 is
bit 0,xe0 is bit 1,…) SRCIP data32 data32 DSTIP data32 data32 IPPROTOCOL Data8 Data8 L4SRCPORT Data16 Data16 L4DSTPORT Data16 Data16 SRCMAC Data48 Data48 DSTMAC Data48 Data48 SRCTRUNK Data16 Data16 ETHERTYPE Data16 Data16 INNERVLAN Data16 Data16 OUTERVLAN Data16 Data16
None
adlink_acl_action_info_t
typedef struct adlink_acl_action_info { adlink_action_type_t type; adlink_acl_data_t param0;//union,use the correct member for different types adlink_acl_data_t param1;//union,use the correct member for different types } adlink_acl_action_info_t;
35
Page 36
Switch Manager API Programming Guide
Table 6- 4, Data Descriptions for Different Action Types
Action Type Param0 Param1 REDIRECTPORT data32 (port bit maps, only one
port is allowed, cpu0 is bit 0,
xe0 is bit 1,…) REDIRECTTRUNK Data16 None DROP None None
None
adlink_acl_rule_info_t
typedef struct adlink_acl_rule_info { UINT16 priority; // the priority of the ACL rule UINT16 qualifier_num; //the number of qualifier of the ACL rule adlink_acl_qualifier_info_t qualifier[MAX_QUALIFIER_NUM]; //record the qualifier info adlink_acl_action_info_t action;// record the action info } adlink_acl_rule_info_t;
Functionsadlink_acl_rule_add ()
PROTOTYPE
status_t adlink_acl_rule_add (adlink_acl_rule_info_t *rule_info,UINT16 *rule_id);
DESCRIPTION
This function is used to add an ACL rule.
PARAMETERS rule_info [IN] the ACL rule info needed to be added. rule_id [OUT] the pointer for saving the rule ID.
RETURN See the description of status_t in Section 1.
adlink_acl_rule_delete ()
PROTOTYPE
status_t adlink_acl_rule_delete (UINT16 rule_id);
36
Page 37
Switch Manager API Programming Guide
DESCRIPTION
This function is used to delete an ACL rule.
PARAMETERS
rule _id [IN] the ID of the ACL rule that want to delete.
RETURN See the description of status_t in Section 1.
adlink_acl_rule_clear ()
PROTOTYPE
status_t adlink_acl_clear ();
DESCRIPTION
This function is used to clear the ACL table in the system. After executing this function, all ACL rules in the system will be lost.
PARAMETERS
None
RETURN See the description of status_t in Section 1.
adlink_acl_rule_get ()
PROTOTYPE
status_t adlink_acl_rule_get (UINT16 rule_id, adlink_acl_rule_info_t *rule_info);
DESCRIPTION
This function is used to get the detail information of an ACL rule.
PARAMETERS
rule_id [IN] The ID of the rule that want to get information. rule_info [OUT] The pointer for saving the rule information.
RETURN
See the description of status_t in Section 1.
37
Page 38
Switch Manager API Programming Guide
Section 7: Static Route
This section describes the macro, enum, struct and function for route. They are defined in the header file “adlink_api_route.h”.

Macro Definitions

MAX_ROUTE_ENTRY_ONE_TIME_GET

This macro is used for getting route entries from the server. Due to packet size limitations allowed in the network (MTU), it isn't possible to get all the entries at once. This macro defines the maximum number of entries retrievable at one time.

Enum Type

None

Data Structure

adlink_route_info_t
typedef struct adlink_route_info { UINT32 ip_addr; //ip address UINT32 ip_mask; //ip mask UINT32 gateway_ip; // next hop ip address UINT16 out_port; //exit port ID UINT16 resv; // alignment } adlink_route_info_t;
38
Page 39

Functions

adlink_route_add ()
PROTOTYPE
status_t adlink_route_add (adlink_route_info_t *route_info);
DESCRIPTION
This function is used to add a rule entry.
PARAMETERS
route_info [IN] route info that want to add.
RETURN
See the description of status_t in Section 1.
Switch Manager API Programming Guide
adlink_route_delete ()
PROTOTYPE
status_t adlink_route_delete (UINT32 ip_addr,UINT32 ip_mask);
DESCRIPTION
This function is used to delete a route entry.
PARAMETERS
ip_addr [IN] ip address that want to delete. ip_mask [IN] ip mask that want to delete.
RETURN See the description of status_t in Section 1.
adlink_route_table_clear ()
PROTOTYPE
status_t adlink_route_table_clear ();
DESCRIPTION
This function is used to clear all routing table entries that have been added by users.
39
Page 40
Switch Manager API Programming Guide
PARAMETERS
None
RETURN See the description of status_t in Section 1.
adlink_route_table_dump ()
PROTOTYPE
status_t adlink_route_table_dump (UINT32 ip_last, UINT32 mask_last, int *count, adlink_route_info_t *route_info);
DESCRIPTION
This function is used to get all route entry info that has been added.
PARAMETERS
ip_last /mask_last [IN] These two parameters pass the last route entry that was retrieved. The
function call will start retrieving route entry info after these values. Set both of these parameters to 0 the first time this function is called.
Count [OUT] This parameter passes the number of route entry values retreived. If
"Count" is less than MAX_ROUTE_ENTRY_ONE_TIME_GET, then all the route entries have been retrieved. Otherwise, we need to call this function again to continue retrieving route entry info.
route_info [OUT] This parameter is the pointer for saving the route entry info. It must have
enough space to save as many as MAX_ROUTE_ENTRY_ONE_TIME_GET route entries.
RETURN
See the description of status_t in Section 1.
40
Page 41
Switch Manager API Programming Guide

Getting Service

ADLINK Technology, Inc.
Address: 9F, No.166 Jian Yi Road, Zhonghe District New Taipei City 235, Taiwan Tel: +886-2-8226-5877 Fax: +886-2-8226-5717 Email: service@adlinktech.com
Ampro ADLINK Technology, Inc.
Address: 5215 Hellyer Avenue, #110, San Jose, CA 95138, USA Tel: +1-408-360-0200 Toll Free: +1-800-966-5200 (USA only) Fax: +1-408-360-0222 Email: info@adlinktech.com
ADLINK Technology (China) Co., Ltd.
Address: 300 Fang Chun Rd., Zhangjiang Hi-Tech Park, Pudong New Area, Shanghai, 201203 China Tel: +86-21-5132-8988 Fax: +86-21-5132-3588 Email: market@adlinktech.com
ADLINK Technology Beijing
Address: Rm. 801, Power Creative E, No. 1, B/D Shang Di East Rd., Beijing, 100085 China Tel: +86-10-5885-8666 Fax: +86-10-5885-8625 Email: market@adlinktech.com
ADLINK Technology Shenzhen
Address: 2F, C Block, Bldg. A1, Cyber-Tech Zone, Gao Xin Ave. Sec. 7, High-Tech Industrial Park S., Shenzhen, 518054 China Tel: +86-755-2643-4858 Fax: +86-755-2664-6353 Email: market@adlinktech.com
LiPPERT ADLINK Technology GmbH
Address: Hans-Thoma-Strasse 11, D-68163, Mannheim, Germany Tel: +49-621-43214-0 Fax: +49-621 43214-30 Email: emea@adlinktech.com
ADLINK Technology, Inc. (French Liaison Office)
Address: 15 rue Emile Baudot, 91300 Massy CEDEX, France Tel: +33 (0) 1 60 12 35 66 Fax: +33 (0) 1 60 12 35 66 Email: france@adlinktech.com
41
Page 42
Switch Manager API Programming Guide
ADLINK Technology Japan Corporation
Address: KANDA374 Bldg. 4F, 3-7-4 Kanda Kajicho, Chiyoda-ku, Tokyo 101-0045, Japan Tel: +81-3-4455-3722 Fax: +81-3-5209-6013 Email: japan@adlinktech.com
ADLINK Technology, Inc. (Korean Liaison Office)
Address: 8F Mointer B/D,1675-12, Seocho-Dong, Seocho-Gu, Seoul 137-070, Korea Tel: +82-2-2057-0565 Fax: +82-2-2057-0563 Email: korea@adlinktech.com
ADLINK Technology Singapore Pte. Ltd.
Address: 84 Genting Lane #07-02A, Cityneon Design Centre, Singapore 349584 Tel: +65-6844-2261 Fax: +65-6844-2263 Email: singapore@adlinktech.com
ADLINK Technology Singapore Pte. Ltd. (Indian Liaison Office)
Address: 1st Floor, #50-56 (Between 16th/17th Cross) Margosa Plaza, Margosa Main Road, Malleswaram, Bangalore-560055, India Tel: +91-80-65605817, +91-80-42246107 Fax: +91-80- 23464606 Email: india@adlinktech.com
42
Loading...