1/* 2 ************************************************************************** 3 * Copyright (c) 2014 - 2015, 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_n2h.h 19 * NSS to HLOS interface definitions. 20 */ 21 22/* 23 * TODO: Since this is the now the public header file for writting an 24 * IPv4 message, we need to convert the entire file to doxygen. 25 */ 26 27#ifndef __NSS_N2H_H 28#define __NSS_N2H_H 29 30#define MAX_PAGES_PER_MSG 32 31 32/* 33 * Private data structure for configure general configs 34 */ 35struct nss_n2h_cfg_pvt { 36 struct semaphore sem; /* Semaphore structure */ 37 struct completion complete; /* completion structure */ 38 int empty_buf_pool; /* valid entry */ 39 int low_water; /* valid entry */ 40 int high_water; /* valid entry */ 41 int response; /* Response from FW */ 42}; 43 44/* 45 * Request/Response types 46 */ 47enum nss_n2h_metadata_types { 48 NSS_RX_METADATA_TYPE_N2H_STATS_SYNC=0, 49 NSS_TX_METADATA_TYPE_N2H_RPS_CFG, 50 NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG, 51 NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS, 52 NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG, 53 NSS_METADATA_TYPE_N2H_ADD_BUF_POOL, 54 NSS_TX_METADATA_TYPE_SET_WATER_MARK, 55 NSS_TX_METADATA_TYPE_GET_PAYLOAD_INFO, 56 NSS_METADATA_TYPE_N2H_MAX, 57}; 58 59struct nss_n2h_rps { 60 uint32_t enable; /* Enable NSS RPS */ 61}; 62 63struct nss_n2h_mitigation { 64 uint32_t enable; /* Enable NSS MITIGATION */ 65}; 66 67struct nss_n2h_buf_pool { 68 uint32_t nss_buf_page_size; 69 uint32_t nss_buf_num_pages; 70 void *nss_buf_pool_vaddr[MAX_PAGES_PER_MSG]; 71 uint32_t nss_buf_pool_addr[MAX_PAGES_PER_MSG]; 72}; 73 74/* 75 * Old way of setting number of empty pool buffers (payloads). 76 * NSS FW then sets low water mark to 'n - ring_size' and 77 * high water mark to 'n + ring_size'. 78 */ 79struct nss_n2h_empty_pool_buf { 80 uint32_t pool_size; /* Empty buffer pool size */ 81}; 82 83/* 84 * New way of setting low and high water marks in the NSS FW. 85 */ 86struct nss_n2h_water_mark { 87 /* 88 * Low water mark. Set it to 0 for system to determine automatically. 89 */ 90 uint32_t low_water; 91 92 /* 93 * High water mark. Set it to 0 for system to determine automatically. 94 */ 95 uint32_t high_water; 96}; 97 98struct nss_n2h_payload_info { 99 uint32_t pool_size; /* Empty buffer pool size */ 100 /* 101 * Low water mark. Set it to 0 for system to determine automatically. 102 */ 103 uint32_t low_water; 104 /* 105 * High water mark. Set it to 0 for system to determine automatically. 106 */ 107 uint32_t high_water; 108}; 109 110struct nss_n2h_flush_payloads { 111 uint32_t flag; /* place holder */ 112}; 113 114/* 115 * NSS Pbuf mgr stats 116 */ 117struct nss_n2h_pbuf_mgr_stats { 118 uint32_t pbuf_alloc_fails; /* Pbuf alloc fail */ 119 uint32_t pbuf_free_count; /* Pbuf free count */ 120 uint32_t pbuf_total_count; /* Pbuf total count */ 121}; 122 123/* 124 * The NSS N2H statistics sync structure. 125 */ 126struct nss_n2h_stats_sync { 127 struct nss_cmn_node_stats node_stats; 128 /* Common node stats for N2H */ 129 uint32_t queue_dropped; /* Number of packets dropped because the PE queue is too full */ 130 uint32_t total_ticks; /* Total clock ticks spend inside the PE */ 131 uint32_t worst_case_ticks; /* Worst case iteration of the PE in ticks */ 132 uint32_t iterations; /* Number of iterations around the PE */ 133 134 struct nss_n2h_pbuf_mgr_stats pbuf_ocm_stats; 135 /* Pbuf OCM Stats */ 136 struct nss_n2h_pbuf_mgr_stats pbuf_default_stats; 137 /* Pbuf Default Stats */ 138 139 uint32_t payload_alloc_fails; /* Number of payload alloc failures */ 140 uint32_t payload_free_count; /* Number of payload alloc failures */ 141 142 uint32_t h2n_ctrl_pkts; /* Control packets received from HLOS */ 143 uint32_t h2n_ctrl_bytes; /* Control bytes received from HLOS */ 144 uint32_t n2h_ctrl_pkts; /* Control packets sent to HLOS */ 145 uint32_t n2h_ctrl_bytes; /* Control bytes sent to HLOS */ 146 147 uint32_t h2n_data_pkts; /* Data packets received from HLOS */ 148 uint32_t h2n_data_bytes; /* Data bytes received from HLOS */ 149 uint32_t n2h_data_pkts; /* Data packets sent to HLOS */ 150 uint32_t n2h_data_bytes; /* Data bytes sent to HLOS */ 151 uint32_t tot_payloads; /* Total number of payloads in NSS FW */ 152 uint32_t data_interface_invalid; /* Number of data packets received from host with an invalid interface */ 153}; 154 155/* 156 * Message structure to send/receive phys i/f commands 157 */ 158struct nss_n2h_msg { 159 struct nss_cmn_msg cm; /* Message Header */ 160 union { 161 struct nss_n2h_stats_sync stats_sync; /* Message: N2H stats sync */ 162 struct nss_n2h_rps rps_cfg; /* Message: RPS configuration */ 163 struct nss_n2h_empty_pool_buf empty_pool_buf_cfg; 164 /* Message: empty pool buf configuration */ 165 struct nss_n2h_flush_payloads flush_payloads; 166 /* Message: flush payloads present in NSS */ 167 struct nss_n2h_mitigation mitigation_cfg; 168 /* Message: Mitigation configuration */ 169 struct nss_n2h_buf_pool buf_pool; /* Message: pbuf coniguration */ 170 struct nss_n2h_water_mark wm; 171 /* Message: Sets low and high water marks */ 172 struct nss_n2h_payload_info payload_info; 173 /* Message: Gets payload info */ 174 } msg; 175}; 176 177/** 178 * Callback to be called when IPv4 message is received 179 */ 180typedef void (*nss_n2h_msg_callback_t)(void *app_data, struct nss_n2h_msg *msg); 181 182/* 183 * nss_n2h_tx_msg() 184 * API to send messaged to n2h package. 185 */ 186extern nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm); 187 188/* 189 * nss_n2h_tx() 190 * API to enable/disable Host RPS support in NSS 191 */ 192extern nss_tx_status_t nss_n2h_rps_cfg(struct nss_ctx_instance *nss_ctx, int enable_rps); 193 194/* 195 * nss_n2h_mitigation_cfg() 196 * API to enable/disable Host MITIGATION support in NSS 197 */ 198extern nss_tx_status_t nss_n2h_mitigation_cfg(struct nss_ctx_instance *nss_ctx, int enable_mitigation, nss_core_id_t nss_core); 199 200/* 201 * nss_n2h_buf_pool_cfg() 202 * API to increase the pbufs on NSS using Host memory 203 */ 204extern nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx, int nss_pbuf_pool_size, nss_core_id_t nss_core); 205 206/* 207 * nss_n2h_empty_pool_buf_register_sysctl() 208 * API to register sysctl for empty pool buffer in n2h. 209 */ 210extern void nss_n2h_empty_pool_buf_register_sysctl(void); 211 212/* 213 * nss_n2h_empty_pool_buf_unregister_sysctl() 214 * API to unregister sysctl for empty pool buffer in n2h. 215 */ 216extern void nss_n2h_empty_pool_buf_unregister_sysctl(void); 217 218/* 219 * nss_n2h_flush_payloads() 220 * API to send flush payloads message to NSS 221 */ 222extern nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx); 223 224/* 225 * nss_n2h_msg_init() 226 * API to initialize the message for N2H package from Host to NSS 227 */ 228extern void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, 229 nss_n2h_msg_callback_t cb, void *app_data); 230 231extern struct nss_ctx_instance *nss_ipv4_notify_register(nss_ipv4_msg_callback_t cb, void *app_data); 232#endif // __NSS_N2H_H 233 234 235