Myricom logotype

snf.h

00001 /*************************************************************************
00002  * The contents of this file are subject to the MYRICOM SNIFFER10G
00003  * LICENSE (the "License"); User may not use this file except in
00004  * compliance with the License.  The full text of the License can found
00005  * in LICENSE.TXT
00006  *
00007  * Software distributed under the License is distributed on an "AS IS"
00008  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
00009  * the License for the specific language governing rights and
00010  * limitations under the License.
00011  *
00012  * Copyright 2008-2009 by Myricom, Inc.  All rights reserved.
00013  ***********************************************************************/
00014 
00230 #ifndef _snf_h
00231 #define _snf_h
00232 
00233 #include <stdint.h>
00234 
00235 #ifdef __cplusplus
00236 extern "C"
00237 {
00238 #endif
00239 
00398 #define SNF_VERSION_API 0x0002
00399 
00404 typedef struct snf_handle *snf_handle_t;
00405 
00418 int  snf_init(uint16_t api_version); /* must be SNF_VERSION_API */
00419 
00420 
00422 struct snf_ifaddrs {
00423   struct snf_ifaddrs *snf_ifa_next;      
00424   const char *snf_ifa_name;       
00425   uint32_t    snf_ifa_boardnum;   
00426   int         snf_ifa_maxrings;   
00427   uint8_t     snf_ifa_macaddr[6]; 
00428 };
00429 
00444 int  snf_getifaddrs(struct snf_ifaddrs **ifaddrs_o);
00445 
00451 void snf_freeifaddrs(struct snf_ifaddrs *ifaddrs);
00452 
00453 struct snf_recv_req;
00454 
00460 enum snf_rss_params_mode { 
00461   SNF_RSS_FLAGS = 0, 
00462   SNF_RSS_FUNCTION = 1 
00463 };
00464 
00481 enum snf_rss_mode_flags {
00482   SNF_RSS_IP        =  0x01, 
00483   SNF_RSS_SRC_PORT  =  0x10, 
00484   SNF_RSS_DST_PORT  =  0x20  
00485 };
00486 #define SNF_RSS_IPV4 SNF_RSS_IP 
00493 struct snf_rss_mode_function {
00494 
00542   uint32_t   (*rss_hash_fn)(struct snf_recv_req *r, void *context);
00545   void        *rss_context;
00546 };
00547 
00575 struct snf_rss_params {
00576   enum snf_rss_params_mode mode; 
00577   union {
00578     enum snf_rss_mode_flags      rss_flags; 
00579     struct snf_rss_mode_function rss_function; 
00580   } params; 
00581 };
00597 #define SNF_F_PSHARED 0x1
00598 
00610 #define SNF_F_RX_DUPLICATE 0x300
00611 
00618 #define SNF_F_RX_PRIVATE 0x100
00619 
00679 int snf_open(uint32_t boardnum,
00680              int num_rings,
00681              const struct snf_rss_params *rss_parms,
00682              int64_t dataring_sz,
00683              int flags,
00684              snf_handle_t *devhandle);
00685 
00696 int snf_start(snf_handle_t devhandle);
00697 
00711 int snf_stop(snf_handle_t devhandle);
00712 
00729 int snf_close(snf_handle_t devhandle);
00730 
00735 typedef struct snf_ring   *snf_ring_t;
00736 
00751 int snf_ring_open(snf_handle_t devhandle, snf_ring_t *ringh);
00752 
00771 int snf_ring_close(snf_ring_t ringh);
00772 
00776 struct snf_recv_req {
00777   void    *pkt_addr;  
00778   uint32_t length;    
00779   uint64_t timestamp; 
00780   uint64_t token;     
00781 };
00782 
00820 int snf_ring_recv(snf_ring_t ringh, int timeout_ms, struct snf_recv_req *recv_req);
00821 
00827 struct snf_ring_stats {
00828   uint64_t  nic_pkt_recv;       
00829   uint64_t  nic_pkt_overflow;   
00830   uint64_t  nic_pkt_bad;        
00831   uint64_t  ring_pkt_recv;      
00832   uint64_t  ring_pkt_overflow;  
00833   uint64_t  nic_bytes_recv;     
00837 };
00838 
00854 int snf_ring_getstats(snf_ring_t ringh, struct snf_ring_stats *stats);
00855 
00857 #ifdef __cplusplus
00858 }
00859 #endif
00860 #endif /* _snf_h */

Myricom banner
26 October 2010 Sniffer10G 1.0.2_pcap1.1.1