Changeset View
Standalone View
sys/dev/sume/adapter.h
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
/*- | |||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | |||||
* | |||||
* Copyright (c) 2015 University of Cambridge All rights reserved. | |||||
* Copyright (c) 2015 Bjoern A. Zeeb All rights reserved. | |||||
* Copyright (c) 2020 Denis Salopek All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
rgrimes: Factoring out of "All rights reserved" leaves it ambiguous to whom has or has not asserted it. | |||||
Done Inline ActionsThe UCAM was not even mentioned as copyright holder in the original Bjoern's Linux driver, so Denis should remove it here and elsewhere. zec: The UCAM was not even mentioned as copyright holder in the original Bjoern's Linux driver, so… | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
Done Inline ActionsCould the Grant clause be moved to after the copyright/license clauses so that it does not interfere with the normal flow of those sections? rgrimes: Could the Grant clause be moved to after the copyright/license clauses so that it does not… | |||||
Done Inline ActionsCertainly not without a permission from Cambridge people. We already spent a month waiting for a permission from them to (re)use Bjoern's Linux source from their private repo, and in particular to remove an additional proprietary licensing clause that was attached to the file. To proceed with your proposal we should ask UCAM again, but IMO it's not worth it, and we couldn't blame them if they would decline (possibly due to contractual obligations to their sponsors). Therefore, Denis pls. revert this. zec: Certainly not without a permission from Cambridge people. We already spent a month waiting for… | |||||
Done Inline ActionsI see nothing in any part of the grant statement, or in the license that says one word about position or for that mater even appearance of this text in the file. Normally these grants require the author to attach this text to the work, without care to location, and they have not protected there text with anything that says someone can not remove it at a future date for that mater, though I am NOT proposing that be done. Who listed did work under that grant and can speak to the text of the grant agreement? rgrimes: I see nothing in any part of the grant statement, or in the license that says one word about… | |||||
Done Inline ActionsI retract my request to move the grant clause. rgrimes: I retract my request to move the grant clause. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||||
* POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* This software was developed by Stanford University and the University of | |||||
* Cambridge Computer Laboratory under National Science Foundation under Grant | |||||
* No. CNS-0855268, the University of Cambridge Computer Laboratory under EPSRC | |||||
* INTERNET Project EP/H040536/1 and by the University of Cambridge Computer | |||||
* Laboratory under DARPA/AFRL contract FA8750-11-C-0249 ("MRC2"), as part of | |||||
* the DARPA MRC research programme. | |||||
*/ | |||||
Done Inline ActionsI'll leave the comment for the sake of leaving it: the reason I have not suggested changing this to the FreeBSD OUI using the dynamic (random) allocator is that some of the NetFPGA infrastructure might still have that hardcoded elsewhere and we'd probably want things to work there (e.g, test suites or others). Not sure to which extend this is still true but I'd leave it for now. bz: I'll leave the comment for the sake of leaving it: the reason I have not suggested changing… | |||||
/* $FreeBSD$ */ | |||||
#define DEFAULT_ETHER_ADDRESS "\02SUME\00" | |||||
#define SUME_ETH_DEVICE_NAME "sume" | |||||
#define SUME_NPORTS 4 | |||||
#define SUME_IOCTL_CMD_WRITE_REG (SIOCGPRIVATE_0) | |||||
#define SUME_IOCTL_CMD_READ_REG (SIOCGPRIVATE_1) | |||||
#define SUME_LOCK(adapter) mtx_lock(&adapter->lock); | |||||
#define SUME_UNLOCK(adapter) mtx_unlock(&adapter->lock); | |||||
/* Currently SUME only uses 2 fixed channels for all port traffic and regs. */ | |||||
#define SUME_RIFFA_CHANNEL_DATA 0 | |||||
#define SUME_RIFFA_CHANNEL_REG 1 | |||||
#define SUME_RIFFA_CHANNELS 2 | |||||
/* RIFFA constants. */ | |||||
#define RIFFA_MAX_CHNLS 12 | |||||
#define RIFFA_MAX_BUS_WIDTH_PARAM 4 | |||||
#define RIFFA_SG_BUF_SIZE (4*1024) | |||||
#define RIFFA_SG_ELEMS 200 | |||||
/* RIFFA register offsets. */ | |||||
#define RIFFA_RX_SG_LEN_REG_OFF 0x0 | |||||
#define RIFFA_RX_SG_ADDR_LO_REG_OFF 0x1 | |||||
#define RIFFA_RX_SG_ADDR_HI_REG_OFF 0x2 | |||||
#define RIFFA_RX_LEN_REG_OFF 0x3 | |||||
#define RIFFA_RX_OFFLAST_REG_OFF 0x4 | |||||
#define RIFFA_TX_SG_LEN_REG_OFF 0x5 | |||||
#define RIFFA_TX_SG_ADDR_LO_REG_OFF 0x6 | |||||
#define RIFFA_TX_SG_ADDR_HI_REG_OFF 0x7 | |||||
#define RIFFA_TX_LEN_REG_OFF 0x8 | |||||
#define RIFFA_TX_OFFLAST_REG_OFF 0x9 | |||||
#define RIFFA_INFO_REG_OFF 0xA | |||||
#define RIFFA_IRQ_REG0_OFF 0xB | |||||
#define RIFFA_IRQ_REG1_OFF 0xC | |||||
#define RIFFA_RX_TNFR_LEN_REG_OFF 0xD | |||||
#define RIFFA_TX_TNFR_LEN_REG_OFF 0xE | |||||
#define RIFFA_CHNL_REG(c, o) ((c << 4) + o) | |||||
/* | |||||
* RIFFA state machine; | |||||
* rather than using complex circular buffers for 1 transaction. | |||||
*/ | |||||
#define SUME_RIFFA_CHAN_STATE_IDLE 0x01 | |||||
#define SUME_RIFFA_CHAN_STATE_READY 0x02 | |||||
#define SUME_RIFFA_CHAN_STATE_READ 0x04 | |||||
#define SUME_RIFFA_CHAN_STATE_LEN 0x08 | |||||
/* Various bits and pieces. */ | |||||
#define SUME_RIFFA_MAGIC 0xcafe | |||||
#define SUME_MR_WRITE 0x1f | |||||
#define SUME_MR_READ 0x00 | |||||
/* Accessor macros. */ | |||||
#define SUME_OFFLAST ((0 << 1) | (1 & 0x01)) | |||||
#define SUME_RIFFA_LAST(offlast) ((offlast) & 0x01) | |||||
#define SUME_RIFFA_OFFSET(offlast) ((uint64_t)((offlast) >> 1) << 2) | |||||
#define SUME_RIFFA_LEN(len) ((uint64_t)(len) << 2) | |||||
#define SUME_RIFFA_LO_ADDR(addr) (addr & 0xFFFFFFFF) | |||||
#define SUME_RIFFA_HI_ADDR(addr) ((addr >> 32) & 0xFFFFFFFF) | |||||
/* Vector bits. */ | |||||
#define SUME_MSI_RXQUE (1 << 0) | |||||
#define SUME_MSI_RXBUF (1 << 1) | |||||
#define SUME_MSI_RXDONE (1 << 2) | |||||
#define SUME_MSI_TXBUF (1 << 3) | |||||
#define SUME_MSI_TXDONE (1 << 4) | |||||
/* Invalid vector. */ | |||||
#define SUME_INVALID_VECT 0xc0000000 | |||||
#define SUME_DPORT_MASK 0xaa | |||||
#define SUME_MIN_PKT_SIZE (ETHER_MIN_LEN - ETHER_CRC_LEN) | |||||
/* Module register data (packet counters, link status...) */ | |||||
#define SUME_MOD0_REG_BASE 0x44040000 | |||||
#define SUME_MOD_REG(port) (SUME_MOD0_REG_BASE + 0x10000 * port) | |||||
#define SUME_RESET_OFFSET 0x8 | |||||
#define SUME_PKTIN_OFFSET 0x18 | |||||
#define SUME_PKTOUT_OFFSET 0x1c | |||||
#define SUME_STATUS_OFFSET 0x48 | |||||
#define SUME_RESET_ADDR(p) (SUME_MOD_REG(p) + SUME_RESET_OFFSET) | |||||
#define SUME_STAT_RX_ADDR(p) (SUME_MOD_REG(p) + SUME_PKTIN_OFFSET) | |||||
#define SUME_STAT_TX_ADDR(p) (SUME_MOD_REG(p) + SUME_PKTOUT_OFFSET) | |||||
#define SUME_STATUS_ADDR(p) (SUME_MOD_REG(p) + SUME_STATUS_OFFSET) | |||||
#define SUME_LINK_STATUS(val) ((val >> 12) & 0x1) | |||||
struct irq { | |||||
struct resource *res; | |||||
uint32_t rid; | |||||
void *tag; | |||||
} __aligned(CACHE_LINE_SIZE); | |||||
struct nf_stats { | |||||
uint64_t rx_packets; | |||||
uint64_t rx_dropped; | |||||
uint64_t rx_bytes; | |||||
uint64_t tx_packets; | |||||
uint64_t tx_dropped; | |||||
uint64_t tx_bytes; | |||||
uint64_t hw_rx_packets; | |||||
uint64_t hw_tx_packets; | |||||
uint64_t ifc_down_packets; | |||||
uint64_t ifc_down_bytes; | |||||
}; | |||||
struct riffa_chnl_dir { | |||||
char *buf_addr; /* bouncebuf addresses+len. */ | |||||
bus_addr_t buf_hw_addr; /* -- " -- mapped. */ | |||||
uint32_t num_sg; | |||||
uint32_t state; | |||||
uint32_t recovery; | |||||
uint32_t offlast; | |||||
uint32_t len; /* words */ | |||||
uint32_t rtag; | |||||
bus_dma_tag_t my_tag; | |||||
bus_dmamap_t my_map; | |||||
/* Used only for register read/write */ | |||||
uint32_t event; | |||||
}; | |||||
struct sume_ifreq { | |||||
uint32_t addr; | |||||
uint32_t val; | |||||
}; | |||||
struct nf_priv { | |||||
struct sume_adapter *adapter; | |||||
struct ifnet *ifp; | |||||
zecUnsubmitted Done Inline Actionsifp is set once and never used: prune it. zec: ifp is set once and never used: prune it. | |||||
uint32_t unit; | |||||
uint32_t port; | |||||
uint32_t riffa_channel; | |||||
zecUnsubmitted Done Inline Actionsriffa_channel is set only once to SUME_RIFFA_CHANNEL_DATA, so de facto is used as constant, hence prune it. zec: riffa_channel is set only once to SUME_RIFFA_CHANNEL_DATA, so de facto is used as constant… | |||||
struct ifmedia media; | |||||
struct nf_stats stats; | |||||
}; | |||||
struct sume_adapter { | |||||
device_t dev; | |||||
uint32_t rid; | |||||
struct resource *bar0_addr; | |||||
bus_size_t bar0_len; | |||||
bus_space_tag_t bt; | |||||
bus_space_handle_t bh; | |||||
struct irq irq; | |||||
uint32_t num_chnls; | |||||
zecUnsubmitted Done Inline Actionsnum_chnls is unused, prune it. zec: num_chnls is unused, prune it. | |||||
uint32_t num_sg; | |||||
uint32_t sg_buf_size; | |||||
uint32_t running; | |||||
struct ifnet *ifp[4]; | |||||
zecUnsubmitted Done Inline Actionsshould be *ifp[SUME_NPORTS]; zec: should be *ifp[SUME_NPORTS]; | |||||
struct mtx lock; | |||||
zecUnsubmitted Done Inline Actionsshould be moved to the top of the structure: fields should be sorted by order of use, because prefetchers work they way forwards, not backwards; and because style(9) says so. zec: should be moved to the top of the structure: fields should be sorted by order of use, because… | |||||
struct riffa_chnl_dir **recv; | |||||
struct riffa_chnl_dir **send; | |||||
uint32_t last_ifc; | |||||
uint64_t packets_err; | |||||
uint64_t bytes_err; | |||||
uint32_t sume_debug; | |||||
struct callout timer; | |||||
struct task stat_task; | |||||
struct taskqueue *tq; | |||||
uint32_t wd_counter; | |||||
}; | |||||
/* SUME metadata: | |||||
* sport - not used for RX. For TX, set to 0x02, 0x08, 0x20, 0x80, depending on | |||||
* the sending interface (nf0, nf1, nf2 or nf3). | |||||
* dport - For RX, is set to 0x02, 0x08, 0x20, 0x80, depending on the receiving | |||||
* interface (nf0, nf1, nf2 or nf3). For TX, set to 0x01, 0x04, 0x10, 0x40, | |||||
* depending on the sending HW interface (nf0, nf1, nf2 or nf3). | |||||
* plen - length of the send/receive packet data (in bytes) | |||||
* magic - SUME hardcoded magic number which should be 0xcafe | |||||
* t1, t1 - could be used for timestamping by SUME | |||||
*/ | |||||
struct nf_metadata { | |||||
uint16_t sport; | |||||
uint16_t dport; | |||||
uint16_t plen; | |||||
uint16_t magic; | |||||
uint32_t t1; | |||||
uint32_t t2; | |||||
}; | |||||
/* Used for ioctl communication with the rwaxi program used to read/write SUME | |||||
* internally defined register data. | |||||
* addr - address of the SUME module register to read/write | |||||
* val - value to write/read to/from the register | |||||
* rtag - returned on read: transaction tag, for syncronization | |||||
* optype - 0x1f when writing, 0x00 for reading | |||||
*/ | |||||
struct nf_regop_data { | |||||
uint32_t addr; | |||||
uint32_t val; | |||||
uint32_t rtag; | |||||
uint32_t optype; | |||||
}; | |||||
/* Our bouncebuffer "descriptor". This holds our physical address (lower and | |||||
* upper values) of the beginning of the DMA data to RX/TX. The len is number | |||||
* of words to transmit. | |||||
*/ | |||||
struct nf_bb_desc { | |||||
uint32_t lower; | |||||
uint32_t upper; | |||||
uint32_t len; | |||||
}; |
Factoring out of "All rights reserved" leaves it ambiguous to whom has or has not asserted it. Have all 3 of these? Has only Denis? Technically none of these people need to assert it as this clause is no longer needed on copyrights asserted after August 23, 2000, but one must obtain a copyright holders permission to remove it from There copyright. A more precise way to write the above copyright is: