ADLINK Switch Manager API Programming Guide Manual Revision: 1.00 Revision Date: August 28, 2013 Part Number: 50-1G026-1000 Advance Technologies; Automate the World.
Switch Manager API Programming Guide Revision History Rev Date Description 1.
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.
Switch Manager API Programming Guide Table of Contents Revision History.................................................................................................................... 2 Preface ................................................................................................................................... 3 Table of Contents.................................................................................................................. 4 List of Figures .............................
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 () ......................................................................................
Switch Manager API Programming Guide adl_nic_config_info_t ..................................................................................................... 23 adl_nic_config_get_cmd_t ............................................................................................. 24 Functions........................................................................................................................... 24 adlink_port_info_get () .................................................................
Switch Manager API Programming Guide adlink_trunk_monitor_del () ........................................................................................... 30 adlink_trunk_monitor_get () ........................................................................................... 30 Section 5: LAYER-2 ............................................................................................................ 31 Macro Definitions................................................................................
Switch Manager API Programming Guide Macro Definitions............................................................................................................... 38 MAX_ROUTE_ENTRY_ONE_TIME_GET .................................................................... 38 Enum Type ........................................................................................................................ 38 Data Structure ............................................................................................
Switch Manager API Programming Guide List of Figures Figure 1,Hardware architecture for programming..........................................................
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 ........................................
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.
Switch Manager API Programming Guide Deliverables The ADLINK Switch Manager Library package (adSwitchLib-x.x.x.tar.
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
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.
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.
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.
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.
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.
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 Manager API Programming Guide 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. 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.
Switch Manager API Programming Guide 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.
Switch Manager API Programming Guide 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
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.
Switch Manager API Programming Guide 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 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.
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.
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.
Switch Manager API Programming Guide PARAMETERS src_port dst_port [IN] Ingress 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.
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.
Switch Manager API Programming Guide 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. 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.
Switch Manager API Programming Guide 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.
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.
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.
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.
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 des
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.
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,…) None REDIRECTTRUNK Data16 None DROP 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]; //recor
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.
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.
Switch Manager API Programming Guide 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. 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.
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 adlink_route_info_t *route_info); (UINT32 ip_last, UINT32 mask_last, int *count, 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.
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.
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.