1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2024 Archermind Technology (Nanjing) Co. Ltd.
3094332d3Sopenharmony_ci *
4094332d3Sopenharmony_ci * HDF is dual licensed: you can use it either under the terms of
5094332d3Sopenharmony_ci * the GPL, or the BSD license, at your option.
6094332d3Sopenharmony_ci * See the LICENSE file in the root of this repository for complete details.
7094332d3Sopenharmony_ci */
8094332d3Sopenharmony_ci
9094332d3Sopenharmony_ci#ifndef USB_NET_NET_H
10094332d3Sopenharmony_ci#define USB_NET_NET_H
11094332d3Sopenharmony_ci
12094332d3Sopenharmony_ci#include "hdf_base.h"
13094332d3Sopenharmony_ci#include "hdf_device_desc.h"
14094332d3Sopenharmony_ci
15094332d3Sopenharmony_ci#define DEFAULT_MTU          1500
16094332d3Sopenharmony_ci#define DEFAULT_NET_HEAD_LEN 14
17094332d3Sopenharmony_ci#define INDEX_ZERO  0
18094332d3Sopenharmony_ci#define INDEX_ONE   1
19094332d3Sopenharmony_ci#define INDEX_TWO   2
20094332d3Sopenharmony_ci/**
21094332d3Sopenharmony_ci * ether_addr_copy - Copy an Ethernet address
22094332d3Sopenharmony_ci * @dst: Pointer to a six-byte array Ethernet address destination
23094332d3Sopenharmony_ci * @src: Pointer to a six-byte array Ethernet address source
24094332d3Sopenharmony_ci *
25094332d3Sopenharmony_ci * Please note: dst & src must both be aligned to uint16_t.
26094332d3Sopenharmony_ci */
27094332d3Sopenharmony_ci#if defined(__i386) || defined(__x86_64) || defined(__s390x__) || defined(__aarch64__)
28094332d3Sopenharmony_ci#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1
29094332d3Sopenharmony_ci#endif
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_cistatic inline void etherAddrCopy(uint8_t *dst, const uint8_t *src)
32094332d3Sopenharmony_ci{
33094332d3Sopenharmony_ci#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
34094332d3Sopenharmony_ci    *(uint32_t *)dst = *(const uint32_t *)src;
35094332d3Sopenharmony_ci    *(uint16_t *)(dst + 4) = *(const uint16_t *)(src + 4);
36094332d3Sopenharmony_ci#else
37094332d3Sopenharmony_ci    uint16_t *a = (uint16_t *)dst;
38094332d3Sopenharmony_ci    const uint16_t *b = (const uint16_t *)src;
39094332d3Sopenharmony_ci
40094332d3Sopenharmony_ci    a[INDEX_ZERO] = b[INDEX_ZERO];
41094332d3Sopenharmony_ci    a[INDEX_ONE]  = b[INDEX_ONE];
42094332d3Sopenharmony_ci    a[INDEX_TWO]  = b[INDEX_TWO];
43094332d3Sopenharmony_ci#endif
44094332d3Sopenharmony_ci}
45094332d3Sopenharmony_ci
46094332d3Sopenharmony_civoid UsbnetWriteLog(char *buff, int size, int tag);
47094332d3Sopenharmony_ci
48094332d3Sopenharmony_ci#endif