cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

rq_enet_desc.h (1923B)


      1/*
      2 * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
      3 * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
      4 *
      5 * This program is free software; you may redistribute it and/or modify
      6 * it under the terms of the GNU General Public License as published by
      7 * the Free Software Foundation; version 2 of the License.
      8 *
      9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
     13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
     14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     16 * SOFTWARE.
     17 */
     18#ifndef _RQ_ENET_DESC_H_
     19#define _RQ_ENET_DESC_H_
     20
     21/* Ethernet receive queue descriptor: 16B */
     22struct rq_enet_desc {
     23	__le64 address;
     24	__le16 length_type;
     25	u8 reserved[6];
     26};
     27
     28enum rq_enet_type_types {
     29	RQ_ENET_TYPE_ONLY_SOP = 0,
     30	RQ_ENET_TYPE_NOT_SOP = 1,
     31	RQ_ENET_TYPE_RESV2 = 2,
     32	RQ_ENET_TYPE_RESV3 = 3,
     33};
     34
     35#define RQ_ENET_ADDR_BITS		64
     36#define RQ_ENET_LEN_BITS		14
     37#define RQ_ENET_LEN_MASK		((1 << RQ_ENET_LEN_BITS) - 1)
     38#define RQ_ENET_TYPE_BITS		2
     39#define RQ_ENET_TYPE_MASK		((1 << RQ_ENET_TYPE_BITS) - 1)
     40
     41static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
     42	u64 address, u8 type, u16 length)
     43{
     44	desc->address = cpu_to_le64(address);
     45	desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
     46		((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
     47}
     48
     49static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
     50	u64 *address, u8 *type, u16 *length)
     51{
     52	*address = le64_to_cpu(desc->address);
     53	*length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
     54	*type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
     55		RQ_ENET_TYPE_MASK);
     56}
     57
     58#endif /* _RQ_ENET_DESC_H_ */