1/* 2 ************************************************************************** 3 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all copies. 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 ************************************************************************** 15 */ 16 17 /* 18 * nss_tun6rd.h 19 * NSS TO HLOS interface definitions. 20 */ 21 22#ifndef __NSS_TUN6RD_H 23#define __NSS_TUN6RD_H 24 25/* 26 * 6RD (IPv6 in IPv4) tunnel messages 27 */ 28 29/** 30 * 6rd tunnel request/response types 31 */ 32enum nss_tun6rd_metadata_types { 33 NSS_TUN6RD_ATTACH_PNODE, 34 NSS_TUN6RD_RX_STATS_SYNC, 35 NSS_TUN6RD_ADD_UPDATE_PEER, 36 NSS_TUN6RD_MAX, 37}; 38 39/** 40 * 6rd tunnel configuration message structure 41 */ 42struct nss_tun6rd_attach_tunnel_msg { 43 uint32_t prefix[4]; /* 6rd prefix */ 44 uint32_t relay_prefix; /* Relay prefix */ 45 uint16_t prefixlen; /* 6rd prefix len */ 46 uint16_t relay_prefixlen; /* Relay prefix length*/ 47 uint32_t saddr; /* Tunnel source address */ 48 uint32_t daddr; /* Tunnel destination addresss */ 49 uint8_t tos; /* Tunnel tos field */ 50 uint8_t ttl; /* Tunnel ttl field */ 51 uint16_t reserved; /* Reserved field */ 52}; 53 54/** 55 * 6rd tunnel statistics sync message structure. 56 */ 57struct nss_tun6rd_sync_stats_msg { 58 struct nss_cmn_node_stats node_stats; /* Node statstics*/ 59}; 60 61/** 62 * 6rd tunnel peer addr. 63 */ 64struct nss_tun6rd_set_peer_msg { 65 uint32_t ipv6_address[4]; /* The peer's ipv6 addr*/ 66 uint32_t dest; /* The peer's ipv4 addr*/ 67}; 68 69/** 70 * Message structure to send/receive 6rd tunnel messages 71 */ 72struct nss_tun6rd_msg { 73 struct nss_cmn_msg cm; /* Message Header */ 74 union { 75 struct nss_tun6rd_attach_tunnel_msg tunnel; /* Message: Attach 6rd tunnel */ 76 struct nss_tun6rd_sync_stats_msg stats; /* Message: interface stats sync */ 77 struct nss_tun6rd_set_peer_msg peer; /* Message: add/update peer */ 78 } msg; 79}; 80 81/** 82 * @brief Callback to receive 6rd tunnel messages 83 * 84 * @param app_data Application context of the message 85 * @param msg Message data 86 * 87 * @return void 88 */ 89typedef void (*nss_tun6rd_msg_callback_t)(void *app_data, struct nss_tun6rd_msg *msg); 90 91/** 92 * @brief Send 6rd tunnel messages 93 * 94 * @param nss_ctx NSS context 95 * @param msg NSS 6rd tunnel message 96 * 97 * @return nss_tx_status_t Tx status 98 */ 99extern nss_tx_status_t nss_tun6rd_tx(struct nss_ctx_instance *nss_ctx, struct nss_tun6rd_msg *msg); 100 101/** 102 * @brief Get the tun6rd context used in the nss_tun6rd_tx 103 * 104 * @return struct nss_ctx_instance *NSS context 105 */ 106extern struct nss_ctx_instance *nss_tun6rd_get_context(void); 107 108/** 109 * @brief Callback to receive 6rd tunnel data 110 * 111 * @param app_data Application context of the message 112 * @param skb Pointer to data buffer 113 * 114 * @return void 115 */ 116typedef void (*nss_tun6rd_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); 117 118/** 119 * @brief Register to send/receive 6rd tunnel messages to NSS 120 * 121 * @param if_num NSS interface number 122 * @param tun6rd_callback Callback for 6rd tunnel data 123 * @param msg_callback Callback for 6rd tunnel messages 124 * @param netdev netdevice associated with the 6rd tunnel 125 * @param features denotes the skb types supported by this interface 126 * 127 * @return nss_ctx_instance* NSS context 128 */ 129extern struct nss_ctx_instance *nss_register_tun6rd_if(uint32_t if_num, nss_tun6rd_callback_t tun6rd_callback, 130 nss_tun6rd_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); 131 132/** 133 * @brief Unregister 6rd tunnel interface with NSS 134 * 135 * @param if_num NSS interface number 136 * 137 * @return void 138 */ 139extern void nss_unregister_tun6rd_if(uint32_t if_num); 140 141/** 142 * @brief Initialize tun6rd msg 143 * @param nss_tun6rd_msg 144 * @param if_num Interface number 145 * @param type Message type 146 * @param len Message length 147 * @param cb message callback 148 * @param app_data 149 * 150 * @return None 151 */ 152extern void nss_tun6rd_msg_init(struct nss_tun6rd_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); 153 154#endif /* __NSS_TUN6RD_H */ 155