Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Copyright 2014 Cisco Systems, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * This program is free software; you may redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifndef __SNIC_RES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define __SNIC_RES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "snic_io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "wq_enet_desc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "vnic_wq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "snic_fwint.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "vnic_cq_fw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) snic_icmnd_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, u64 ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		u16 flags, u64 tgt_id, u8 *lun, u8 *scsi_cdb, u8 cdb_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		u32 data_len, u16 sg_cnt, ulong sgl_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		dma_addr_t sns_addr_pa, u32 sense_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	snic_io_hdr_enc(&req->hdr, SNIC_REQ_ICMND, 0, cmnd_id, host_id, sg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 			ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	req->u.icmnd.flags = cpu_to_le16(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	req->u.icmnd.tgt_id = cpu_to_le64(tgt_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	memcpy(&req->u.icmnd.lun_id, lun, LUN_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	req->u.icmnd.cdb_len = cdb_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	memset(req->u.icmnd.cdb, 0, SNIC_CDB_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	memcpy(req->u.icmnd.cdb, scsi_cdb, cdb_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	req->u.icmnd.data_len = cpu_to_le32(data_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	req->u.icmnd.sg_addr = cpu_to_le64(sgl_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	req->u.icmnd.sense_len = cpu_to_le32(sense_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	req->u.icmnd.sense_addr = cpu_to_le64(sns_addr_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) snic_itmf_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, ulong ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	       u16 flags, u32 req_id, u64 tgt_id, u8 *lun, u8 tm_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	snic_io_hdr_enc(&req->hdr, SNIC_REQ_ITMF, 0, cmnd_id, host_id, 0, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	req->u.itmf.tm_type = tm_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	req->u.itmf.flags = cpu_to_le16(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	/* req_id valid only in abort, clear task */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	req->u.itmf.req_id = cpu_to_le32(req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	req->u.itmf.tgt_id = cpu_to_le64(tgt_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	memcpy(&req->u.itmf.lun_id, lun, LUN_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) snic_queue_wq_eth_desc(struct vnic_wq *wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		       void *os_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		       dma_addr_t dma_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		       unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		       int vlan_tag_insert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		       unsigned int vlan_tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		       int cq_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	struct wq_enet_desc *desc = svnic_wq_next_desc(wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	wq_enet_desc_enc(desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 			(u64)dma_addr | VNIC_PADDR_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 			(u16)len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 			0, /* mss_or_csum_offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 			0, /* fc_eof */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 			0, /* offload mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 			1, /* eop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 			(u8)cq_entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 			0, /* fcoe_encap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 			(u8)vlan_tag_insert,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 			(u16)vlan_tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 			0 /* loopback */);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	svnic_wq_post(wq, os_buf, dma_addr, len, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct snic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int snic_get_vnic_config(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int snic_alloc_vnic_res(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) void snic_free_vnic_res(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) void snic_get_res_counts(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) void snic_log_q_error(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int snic_get_vnic_resources_size(struct snic *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #endif /* __SNIC_RES_H */