forked from vtl/ethblk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethblk.h
89 lines (74 loc) · 2.27 KB
/
ethblk.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 Vitaly Mayatskikh <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2.
*
*/
#ifndef _ETHBLK_H_
#define _ETHBLK_H_
#include <linux/atomic.h>
#include <linux/etherdevice.h>
#include <linux/inetdevice.h>
#include <linux/ip.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include <linux/smp.h>
#include <linux/udp.h>
#include <net/ip.h>
#define VERSION "0.1"
extern int net_stat;
extern unsigned int eth_p_type;
extern char *log_buf;
#define LOG_ENTRY_SIZE 256
extern bool target_mode;
extern bool initiator_mode;
#define dprintk(level, fmt, arg...) \
do { \
int pid, cpu; \
pid = task_pid_nr(current); \
cpu = smp_processor_id(); \
pr_##level( \
"%s[%s pid:%d cpu:%d] " fmt, \
__func__, current->comm, pid, cpu, ##arg); \
} while (0)
#define dprintk_ratelimit(level, fmt, arg...) \
do { \
if (printk_ratelimit()) { \
dprintk(level, fmt, ##arg); \
} \
} while (0)
#define ETHBLK_PROTO_VERSION 1
#define ETHBLK_OP_READ 0
#define ETHBLK_OP_WRITE 1
#define ETHBLK_OP_DISCOVER 2
#define ETHBLK_OP_ID 3
struct ethblk_hdr {
__u8 dst[ETH_ALEN];
__u8 src[ETH_ALEN];
__be16 type;
__u8 version : 4;
__u8 status : 3;
__u8 response : 1;
__u8 op;
__be16 drv_id;
__be64 lba;
__u8 num_sectors;
__be32 tag;
__u8 pad;
} __attribute__((packed));
struct ethblk_cfg_hdr {
__be16 q_depth;
__be16 num_queues;
__be64 num_sectors;
__u8 uuid[32];
} __attribute__((packed));
static inline void ethblk_dump_mac(char *s, int len, unsigned char *mac)
{
snprintf(s, len, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1],
mac[2], mac[3], mac[4], mac[5]);
}
void ethblk_net_init(void);
void ethblk_net_exit(void);
#endif