hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright (C) 2019 Spreadtrum Communications Inc.
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
 
#ifndef __MCHN_H__
#define __MCHN_H__
 
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
 
#define HW_TYPE_SDIO 0
#define HW_TYPE_PCIE 1
#define MCHN_MAX_NUM 32
 
struct buffer_pool {
   int size;
   int free;
   int payload;
   void *head;
   char *mem;
   spinlock_t lock;
   unsigned long irq_flags;
};
 
struct mchn_info_t {
   struct mchn_ops_t *ops[MCHN_MAX_NUM];
   struct {
       struct buffer_pool pool;
   } chn_public[MCHN_MAX_NUM];
};
 
/* configuration channel */
int mchn_init(struct mchn_ops_t *ops);
/* cancellation channel */
int mchn_deinit(struct mchn_ops_t *ops);
/* push link list */
int mchn_push_link(int channel, struct mbuf_t *head,
          struct mbuf_t *tail, int num);
/* push link list, Using a blocking mode, Timeout wait for tx_complete */
int mchn_push_link_wait_complete(int chn, struct mbuf_t *head,
                struct mbuf_t *tail, int num, int timeout);
int mchn_hw_pop_link(int chn, void *head, void *tail, int num);
int mchn_hw_tx_complete(int chn, int timeout);
int mchn_hw_req_push_link(int chn, int need);
int mbuf_link_alloc(int chn, struct mbuf_t **head, struct mbuf_t **tail,
            int *num);
int mbuf_link_free(int chn, struct mbuf_t *head,
          struct mbuf_t *tail, int num);
int mchn_hw_max_pending(int chn);
struct mchn_info_t *mchn_info(void);
struct mchn_ops_t *mchn_ops(int channel);
#endif