Home | History | Annotate | Line # | Download | only in lagg
if_lagg_lacp.h revision 1.5
      1  1.5  yamaguch /*	$NetBSD: if_lagg_lacp.h,v 1.5 2023/11/22 03:49:13 yamaguchi Exp $	*/
      2  1.2  yamaguch 
      3  1.2  yamaguch /*
      4  1.2  yamaguch  * Copyright (c) 2021 Internet Initiative Japan Inc.
      5  1.2  yamaguch  * All rights reserved.
      6  1.2  yamaguch  *
      7  1.2  yamaguch  * Redistribution and use in source and binary forms, with or without
      8  1.2  yamaguch  * modification, are permitted provided that the following conditions
      9  1.2  yamaguch  * are met:
     10  1.2  yamaguch  * 1. Redistributions of source code must retain the above copyright
     11  1.2  yamaguch  *    notice, this list of conditions and the following disclaimer.
     12  1.2  yamaguch  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2  yamaguch  *    notice, this list of conditions and the following disclaimer in the
     14  1.2  yamaguch  *    documentation and/or other materials provided with the distribution.
     15  1.2  yamaguch  *
     16  1.2  yamaguch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.2  yamaguch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.2  yamaguch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.2  yamaguch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.2  yamaguch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.2  yamaguch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.2  yamaguch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.2  yamaguch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.2  yamaguch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.2  yamaguch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.2  yamaguch  * POSSIBILITY OF SUCH DAMAGE.
     27  1.2  yamaguch  */
     28  1.1  yamaguch 
     29  1.1  yamaguch #ifndef _NET_LAGG_IF_LAGG_LACP_H_
     30  1.1  yamaguch #define _NET_LAGG_IF_LAGG_LACP_H_
     31  1.1  yamaguch 
     32  1.1  yamaguch /* timeout values (in sec) */
     33  1.1  yamaguch #define LACP_FAST_PERIODIC_TIME		1
     34  1.1  yamaguch #define LACP_SLOW_PERIODIC_TIME		30
     35  1.1  yamaguch #define LACP_SHORT_TIMEOUT_TIME		(3 * LACP_FAST_PERIODIC_TIME)
     36  1.1  yamaguch #define LACP_LONG_TIMEOUT_TIME		(3 * LACP_SLOW_PERIODIC_TIME)
     37  1.1  yamaguch #define LACP_CHURN_DETECTION_TIME	60
     38  1.1  yamaguch #define LACP_AGGREGATE_WAIT_TIME	2
     39  1.1  yamaguch #define LACP_TRANSIT_DELAY		3
     40  1.1  yamaguch 
     41  1.1  yamaguch #define LACP_MAX_PORTS		16
     42  1.1  yamaguch #define LACP_SYSTEM_PRIO	0x8000U
     43  1.1  yamaguch #define LACP_PORT_PRIO		LAGG_PORT_PRIO
     44  1.4  yamaguch #define LACP_SENDDU_PPS		3
     45  1.4  yamaguch #define LACP_RCVDU_LIMIT	(LACP_SENDDU_PPS * LACP_MAX_PORTS)
     46  1.1  yamaguch 
     47  1.1  yamaguch #define LACP_PARTNER_ADMIN_OPTIMISTIC	(LACP_STATE_SYNC | \
     48  1.1  yamaguch 					LACP_STATE_AGGREGATION | \
     49  1.1  yamaguch 					LACP_STATE_COLLECTING | \
     50  1.1  yamaguch 					LACP_STATE_DISTRIBUTING)
     51  1.1  yamaguch #define LACP_PARTNER_ADMIN_STRICT	0
     52  1.1  yamaguch 
     53  1.1  yamaguch #define TLV_TYPE_TERMINATE	0
     54  1.1  yamaguch 
     55  1.1  yamaguch #define LACP_TYPE_TERMINATE	TLV_TYPE_TERMINATE
     56  1.1  yamaguch #define LACP_TYPE_ACTORINFO	1
     57  1.1  yamaguch #define LACP_TYPE_PARTNERINFO	2
     58  1.1  yamaguch #define LACP_TYPE_COLLECTORINFO	3
     59  1.1  yamaguch 
     60  1.1  yamaguch #define MARKER_TYPE_TERMINATE	TLV_TYPE_TERMINATE
     61  1.1  yamaguch #define MARKER_TYPE_INFO	1
     62  1.1  yamaguch #define MARKER_TYPE_RESPONSE	2
     63  1.1  yamaguch 
     64  1.1  yamaguch struct tlvhdr {
     65  1.1  yamaguch 	uint8_t		 tlv_type;
     66  1.1  yamaguch 	uint8_t		 tlv_length;
     67  1.1  yamaguch } __packed;
     68  1.1  yamaguch 
     69  1.1  yamaguch struct tlv {
     70  1.1  yamaguch 	uint8_t		 tlv_t;
     71  1.1  yamaguch 	uint8_t		 tlv_l;
     72  1.1  yamaguch 	void		*tlv_v;
     73  1.1  yamaguch };
     74  1.1  yamaguch 
     75  1.1  yamaguch static inline void
     76  1.1  yamaguch tlv_set(struct tlvhdr *th, uint8_t t, uint8_t l)
     77  1.1  yamaguch {
     78  1.1  yamaguch 
     79  1.1  yamaguch 	th->tlv_type = t;
     80  1.1  yamaguch 	th->tlv_length = sizeof(*th) + l;
     81  1.1  yamaguch }
     82  1.1  yamaguch 
     83  1.1  yamaguch struct lacpdu_peerinfo {
     84  1.1  yamaguch 	uint16_t	 lpi_system_prio;
     85  1.1  yamaguch 	uint8_t		 lpi_system_mac[LACP_MAC_LEN];
     86  1.1  yamaguch 	uint16_t	 lpi_key;
     87  1.1  yamaguch 	uint16_t	 lpi_port_prio;
     88  1.1  yamaguch 	uint16_t	 lpi_port_no;
     89  1.1  yamaguch 	uint8_t		 lpi_state;
     90  1.1  yamaguch 	uint8_t		 lpi_resv[3];
     91  1.1  yamaguch } __packed;
     92  1.1  yamaguch 
     93  1.1  yamaguch struct lacpdu_collectorinfo {
     94  1.1  yamaguch 	uint16_t	 lci_maxdelay;
     95  1.1  yamaguch 	uint8_t		 lci_resv[12];
     96  1.1  yamaguch } __packed;
     97  1.1  yamaguch 
     98  1.1  yamaguch struct lacpdu {
     99  1.1  yamaguch 	struct ether_header	 ldu_eh;
    100  1.1  yamaguch 	struct slowprothdr	 ldu_sph;
    101  1.1  yamaguch 
    102  1.1  yamaguch 	struct tlvhdr		 ldu_tlv_actor;
    103  1.1  yamaguch 	struct lacpdu_peerinfo	 ldu_actor;
    104  1.1  yamaguch 	struct tlvhdr		 ldu_tlv_partner;
    105  1.1  yamaguch 	struct lacpdu_peerinfo	 ldu_partner;
    106  1.1  yamaguch 
    107  1.1  yamaguch 	struct tlvhdr		 ldu_tlv_collector;
    108  1.1  yamaguch 	struct lacpdu_collectorinfo
    109  1.1  yamaguch 				 ldu_collector;
    110  1.1  yamaguch 
    111  1.1  yamaguch 	struct tlvhdr		 ldu_tlv_term;
    112  1.1  yamaguch 	uint8_t			 ldu_resv[50];
    113  1.1  yamaguch } __packed;
    114  1.1  yamaguch 
    115  1.1  yamaguch struct markerdu_info {
    116  1.1  yamaguch 	uint16_t	 mi_rq_port;
    117  1.1  yamaguch 	uint8_t		 mi_rq_system[LACP_MAC_LEN];
    118  1.1  yamaguch 	uint32_t	 mi_rq_xid;
    119  1.1  yamaguch 	uint8_t		 mi_pad[2];
    120  1.1  yamaguch } __packed;
    121  1.1  yamaguch 
    122  1.1  yamaguch struct markerdu {
    123  1.1  yamaguch 	struct ether_header	 mdu_eh;
    124  1.1  yamaguch 	struct slowprothdr	 mdu_sph;
    125  1.1  yamaguch 
    126  1.1  yamaguch 	struct tlvhdr		 mdu_tlv_info;
    127  1.1  yamaguch 	struct markerdu_info	 mdu_info;
    128  1.1  yamaguch 
    129  1.1  yamaguch 	struct tlvhdr		 mdu_tlv_term;
    130  1.1  yamaguch 	uint8_t			 mdu_resv[90];
    131  1.1  yamaguch } __packed;
    132  1.1  yamaguch #endif
    133