Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright 2014 Cisco Systems, Inc.  All rights reserved. */
0003 
0004 #ifndef __SNIC_RES_H
0005 #define __SNIC_RES_H
0006 
0007 #include "snic_io.h"
0008 #include "wq_enet_desc.h"
0009 #include "vnic_wq.h"
0010 #include "snic_fwint.h"
0011 #include "vnic_cq_fw.h"
0012 
0013 static inline void
0014 snic_icmnd_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, u64 ctx,
0015         u16 flags, u64 tgt_id, u8 *lun, u8 *scsi_cdb, u8 cdb_len,
0016         u32 data_len, u16 sg_cnt, ulong sgl_addr,
0017         dma_addr_t sns_addr_pa, u32 sense_len)
0018 {
0019     snic_io_hdr_enc(&req->hdr, SNIC_REQ_ICMND, 0, cmnd_id, host_id, sg_cnt,
0020             ctx);
0021 
0022     req->u.icmnd.flags = cpu_to_le16(flags);
0023     req->u.icmnd.tgt_id = cpu_to_le64(tgt_id);
0024     memcpy(&req->u.icmnd.lun_id, lun, LUN_ADDR_LEN);
0025     req->u.icmnd.cdb_len = cdb_len;
0026     memset(req->u.icmnd.cdb, 0, SNIC_CDB_LEN);
0027     memcpy(req->u.icmnd.cdb, scsi_cdb, cdb_len);
0028     req->u.icmnd.data_len = cpu_to_le32(data_len);
0029     req->u.icmnd.sg_addr = cpu_to_le64(sgl_addr);
0030     req->u.icmnd.sense_len = cpu_to_le32(sense_len);
0031     req->u.icmnd.sense_addr = cpu_to_le64(sns_addr_pa);
0032 }
0033 
0034 static inline void
0035 snic_itmf_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, ulong ctx,
0036            u16 flags, u32 req_id, u64 tgt_id, u8 *lun, u8 tm_type)
0037 {
0038     snic_io_hdr_enc(&req->hdr, SNIC_REQ_ITMF, 0, cmnd_id, host_id, 0, ctx);
0039 
0040     req->u.itmf.tm_type = tm_type;
0041     req->u.itmf.flags = cpu_to_le16(flags);
0042     /* req_id valid only in abort, clear task */
0043     req->u.itmf.req_id = cpu_to_le32(req_id);
0044     req->u.itmf.tgt_id = cpu_to_le64(tgt_id);
0045     memcpy(&req->u.itmf.lun_id, lun, LUN_ADDR_LEN);
0046 }
0047 
0048 static inline void
0049 snic_queue_wq_eth_desc(struct vnic_wq *wq,
0050                void *os_buf,
0051                dma_addr_t dma_addr,
0052                unsigned int len,
0053                int vlan_tag_insert,
0054                unsigned int vlan_tag,
0055                int cq_entry)
0056 {
0057     struct wq_enet_desc *desc = svnic_wq_next_desc(wq);
0058 
0059     wq_enet_desc_enc(desc,
0060             (u64)dma_addr | VNIC_PADDR_TARGET,
0061             (u16)len,
0062             0, /* mss_or_csum_offset */
0063             0, /* fc_eof */
0064             0, /* offload mode */
0065             1, /* eop */
0066             (u8)cq_entry,
0067             0, /* fcoe_encap */
0068             (u8)vlan_tag_insert,
0069             (u16)vlan_tag,
0070             0 /* loopback */);
0071 
0072     svnic_wq_post(wq, os_buf, dma_addr, len, 1, 1);
0073 }
0074 
0075 struct snic;
0076 
0077 int snic_get_vnic_config(struct snic *);
0078 int snic_alloc_vnic_res(struct snic *);
0079 void snic_free_vnic_res(struct snic *);
0080 void snic_get_res_counts(struct snic *);
0081 void snic_log_q_error(struct snic *);
0082 int snic_get_vnic_resources_size(struct snic *);
0083 #endif /* __SNIC_RES_H */