ia64/linux-2.6.18-xen.hg

view drivers/net/sfc/sfc_resource/ci/efrm/iobufset.h @ 847:ad4d307bf9ce

net sfc: Update sfc and sfc_resource driver to latest release

...and update sfc_netfront, sfc_netback, sfc_netutil for any API changes

sfc_netback: Fix asymmetric use of SFC buffer table alloc and free
sfc_netback: Clean up if no SFC accel device found
sfc_netback: Gracefully handle case where page grant fails
sfc_netback: Disable net acceleration if the physical link goes down
sfc_netfront: Less verbose error messages, more verbose counters for
rx discard errors
sfc_netfront: Gracefully handle case where SFC netfront fails during
initialisation

Signed-off-by: Kieran Mansley <kmansley@solarflare.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:59:10 2009 +0100 (2009-03-31)
parents e4dd072db259
children
line source
1 /****************************************************************************
2 * Driver for Solarflare network controllers -
3 * resource management for Xen backend, OpenOnload, etc
4 * (including support for SFE4001 10GBT NIC)
5 *
6 * This file provides public API for iobufset resource.
7 *
8 * Copyright 2005-2007: Solarflare Communications Inc,
9 * 9501 Jeronimo Road, Suite 250,
10 * Irvine, CA 92618, USA
11 *
12 * Developed and maintained by Solarflare Communications:
13 * <linux-xen-drivers@solarflare.com>
14 * <onload-dev@solarflare.com>
15 *
16 * Certain parts of the driver were implemented by
17 * Alexandra Kossovsky <Alexandra.Kossovsky@oktetlabs.ru>
18 * OKTET Labs Ltd, Russia,
19 * http://oktetlabs.ru, <info@oktetlabs.ru>
20 * by request of Solarflare Communications
21 *
22 *
23 * This program is free software; you can redistribute it and/or modify it
24 * under the terms of the GNU General Public License version 2 as published
25 * by the Free Software Foundation, incorporated herein by reference.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 ****************************************************************************
36 */
38 #ifndef __CI_EFRM_IOBUFSET_H__
39 #define __CI_EFRM_IOBUFSET_H__
41 #include <ci/efrm/vi_resource.h>
43 /*! Iobufset resource structture.
44 * Users should not access the structure fields directly, but use the API
45 * below.
46 * However, this structure should not be moved out of public headers,
47 * because part of API (ex. efrm_iobufset_dma_addr function) is inline and
48 * is used in the fast-path code.
49 */
50 struct iobufset_resource {
51 struct efrm_resource rs;
52 struct vi_resource *evq;
53 struct efhw_buffer_table_allocation buf_tbl_alloc;
54 unsigned int faultonaccess;
55 unsigned int n_bufs;
56 unsigned int pages_per_contiguous_chunk;
57 unsigned order;
58 struct efhw_iopage bufs[1];
59 /*!< up to n_bufs can follow this, so this must be the last member */
60 };
62 #define iobufset_resource(rs1) \
63 container_of((rs1), struct iobufset_resource, rs)
65 /*!
66 * Allocate iobufset resource.
67 *
68 * \param vi_evq VI resource to use. The function takes
69 * reference to the VI resource on success.
70 * \param iobrs_out pointer to return the new filter resource
71 *
72 * \return status code; if non-zero, frs_out is unchanged
73 */
74 extern int
75 efrm_iobufset_resource_alloc(int32_t n_pages,
76 int32_t pages_per_contiguous_chunk,
77 struct vi_resource *vi_evq,
78 bool phys_addr_mode,
79 uint32_t faultonaccess,
80 struct iobufset_resource **iobrs_out);
82 /* efrm_iobufset_resource_free should be called only if
83 * __efrm_resource_ref_count_zero() returned true.
84 * The easiest way is to call efrm_iobufset_resource_release() */
85 void efrm_iobufset_resource_free(struct iobufset_resource *rs);
86 static inline void
87 efrm_iobufset_resource_release(struct iobufset_resource *iobrs)
88 {
89 unsigned id;
91 EFRM_RESOURCE_ASSERT_VALID(&iobrs->rs, 0);
92 id = EFRM_RESOURCE_INSTANCE(iobrs->rs.rs_handle);
94 if (atomic_dec_and_test(&iobrs->rs.rs_ref_count)) {
95 if (__efrm_resource_ref_count_zero(EFRM_RESOURCE_IOBUFSET, id))
96 efrm_iobufset_resource_free(iobrs);
97 }
98 }
100 static inline char *
101 efrm_iobufset_ptr(struct iobufset_resource *rs, unsigned offs)
102 {
103 EFRM_ASSERT(offs < (unsigned)(rs->n_bufs << PAGE_SHIFT));
104 return efhw_iopage_ptr(&rs->bufs[offs >> PAGE_SHIFT])
105 + (offs & (PAGE_SIZE - 1));
106 }
108 static inline char *efrm_iobufset_page_ptr(struct iobufset_resource *rs,
109 unsigned page_i)
110 {
111 EFRM_ASSERT(page_i < (unsigned)rs->n_bufs);
112 return efhw_iopage_ptr(&rs->bufs[page_i]);
113 }
115 static inline dma_addr_t
116 efrm_iobufset_dma_addr(struct iobufset_resource *rs, unsigned offs)
117 {
118 EFRM_ASSERT(offs < (unsigned)(rs->n_bufs << PAGE_SHIFT));
119 return efhw_iopage_dma_addr(&rs->bufs[offs >> PAGE_SHIFT])
120 + (offs & (PAGE_SIZE - 1));
121 }
123 #endif /* __CI_EFRM_IOBUFSET_H__ */