1/** 2 * @brief 3 * net.h 4 */ 5 6/* 7 * Copyright (c) 2017, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15 16#ifndef LIB_NET_INCLUDE_NETWORKING_BUFFER_H_ 17#define LIB_NET_INCLUDE_NETWORKING_BUFFER_H_ 18 19#define NETWORKING_BUFFER_DEFAULT_SIZE 2048 20 21struct net_buf_pool; 22struct pbuf; 23struct devq; 24 25/** 26 * @brief initializes the networking buffer pools 27 * 28 * @param dev_q the device queue to create the buffer pool for 29 * @param numbuf number of initial buffers 30 * @param size size of the networking buffer 31 * @param retbp buffer pool to initialize 32 * 33 * @return SYS_ERR_OK on success, errval on failure 34 */ 35errval_t net_buf_pool_alloc(struct devq *dev_q, size_t numbuf, size_t size, 36 struct net_buf_pool **retbp); 37 38 39errval_t net_buf_pool_free(struct net_buf_pool *retbp); 40 41 42/** 43 * @brief grows the number of available buffers 44 * 45 * @param bp buffer pool to grow 46 * @param numbuf number of buffers to create 47 * @param size size of a buffer 48 * 49 * @return SYS_ERR_OK on success, errval on failure 50 */ 51errval_t net_buf_grow(struct net_buf_pool *bp, size_t numbuf, 52 size_t size); 53 54/** 55 * @brief adds a previously allocated frame to the buffer pool 56 * 57 * @param bp buffer pool to add the frame to 58 * @param frame frame capability 59 * @param buffersize size of a buffer 60 * 61 * @return SYS_ERR_OK on success, errval on failure 62 */ 63errval_t net_buf_add(struct net_buf_pool *bp, 64 struct capref frame, size_t buffersize); 65 66struct pbuf *net_buf_alloc(struct net_buf_pool *bp); 67 68/** 69 * @brief 70 * @param p 71 */ 72void net_buf_free(struct pbuf *p); 73 74/** 75 * @brief 76 * @param bp 77 * @param regionid 78 * @param offset 79 * @return 80 */ 81struct pbuf *net_buf_get_by_region(struct net_buf_pool *bp, 82 uint32_t regionid, size_t offset); 83 84#endif /* LIB_NET_INCLUDE_NETWORKING_BUFFER_H_ */ 85