18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 78c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 108c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 118c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 128c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 138c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 158c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 168c2ecf20Sopenharmony_ci * SOFTWARE. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#ifndef _RQ_ENET_DESC_H_ 198c2ecf20Sopenharmony_ci#define _RQ_ENET_DESC_H_ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* Ethernet receive queue descriptor: 16B */ 228c2ecf20Sopenharmony_cistruct rq_enet_desc { 238c2ecf20Sopenharmony_ci __le64 address; 248c2ecf20Sopenharmony_ci __le16 length_type; 258c2ecf20Sopenharmony_ci u8 reserved[6]; 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cienum rq_enet_type_types { 298c2ecf20Sopenharmony_ci RQ_ENET_TYPE_ONLY_SOP = 0, 308c2ecf20Sopenharmony_ci RQ_ENET_TYPE_NOT_SOP = 1, 318c2ecf20Sopenharmony_ci RQ_ENET_TYPE_RESV2 = 2, 328c2ecf20Sopenharmony_ci RQ_ENET_TYPE_RESV3 = 3, 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define RQ_ENET_ADDR_BITS 64 368c2ecf20Sopenharmony_ci#define RQ_ENET_LEN_BITS 14 378c2ecf20Sopenharmony_ci#define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1) 388c2ecf20Sopenharmony_ci#define RQ_ENET_TYPE_BITS 2 398c2ecf20Sopenharmony_ci#define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic inline void rq_enet_desc_enc(struct rq_enet_desc *desc, 428c2ecf20Sopenharmony_ci u64 address, u8 type, u16 length) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci desc->address = cpu_to_le64(address); 458c2ecf20Sopenharmony_ci desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) | 468c2ecf20Sopenharmony_ci ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS)); 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline void rq_enet_desc_dec(struct rq_enet_desc *desc, 508c2ecf20Sopenharmony_ci u64 *address, u8 *type, u16 *length) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci *address = le64_to_cpu(desc->address); 538c2ecf20Sopenharmony_ci *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK; 548c2ecf20Sopenharmony_ci *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) & 558c2ecf20Sopenharmony_ci RQ_ENET_TYPE_MASK); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#endif /* _RQ_ENET_DESC_H_ */ 59