Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
28
Issues
28
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
16a21407
Commit
16a21407
authored
Oct 28, 2016
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minic_fifo: transmitting frames with new minic HDL
parent
5ccade7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
21 deletions
+50
-21
minic.c
dev/minic.c
+43
-21
minic.h
include/minic.h
+7
-0
No files found.
dev/minic.c
View file @
16a21407
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2011,2012 CERN (www.cern.ch)
* Copyright (C) 2011,2012
,2016
CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
*
...
...
@@ -35,10 +35,6 @@
#define RXOOB_TS_INCORRECT (1<<11)
#define TX_DESC_VALID (1<<31)
#define TX_DESC_WITH_OOB (1<<30)
#define TX_DESC_HAS_OWN_MAC (1<<28)
#define RX_OOB_SIZE 6
#define ETH_HEADER_SIZE 14
...
...
@@ -63,15 +59,23 @@ static inline uint32_t minic_readl(uint32_t reg)
return
*
(
volatile
uint32_t
*
)(
BASE_MINIC
+
reg
);
}
void
minic_init
(
)
static
inline
void
minic_txword
(
uint8_t
type
,
uint16_t
word
)
{
uint32_t
lo
,
hi
;
minic_writel
(
MINIC_REG_TX_FIFO
,
MINIC_TX_FIFO_TYPE_W
(
type
)
|
MINIC_TX_FIFO_DAT_W
(
word
));
}
minic_writel
(
MINIC_REG_EIC_IDR
,
MINIC_EIC_IDR_RX
);
minic_writel
(
MINIC_REG_EIC_ISR
,
MINIC_EIC_ISR_RX
);
void
minic_init
()
{
uint32_t
mcr
;
/* disable interrupts, driver does polling */
minic_writel
(
MINIC_REG_EIC_IDR
,
MINIC_EIC_IDR_TX
|
MINIC_EIC_IDR_RX
|
MINIC_EIC_IDR_TXTS
);
minic_writel
(
MINIC_REG_EIC_IER
,
MINIC_EIC_IER_RX
);
/* enable RX path */
mcr
=
minic_readl
(
MINIC_REG_MCR
);
minic_writel
(
MINIC_REG_MCR
,
mcr
|
MINIC_MCR_RX_EN
);
}
void
minic_disable
()
...
...
@@ -170,30 +174,49 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
int
minic_tx_frame
(
struct
wr_ethhdr_vlan
*
hdr
,
uint8_t
*
payload
,
uint32_t
size
,
struct
hw_timestamp
*
hwts
)
{
uint32_t
d_hdr
,
mcr
,
n
words
;
uint32_t
d_hdr
,
mcr
,
pwords
,
h
words
;
uint8_t
ts_valid
;
int
i
,
hsize
;
uint16_t
*
ptr
;
if
(
hdr
->
ethtype
==
htons
(
0x8100
))
hsize
=
sizeof
(
struct
wr_ethhdr_vlan
);
else
hsize
=
sizeof
(
struct
wr_ethhdr
);
hwords
=
hsize
>>
1
;
if
(
size
<
60
)
size
=
60
;
nwords
=
((
size
+
1
)
>>
1
);
if
(
size
+
hsize
<
60
)
size
=
60
-
hsize
;
pwords
=
((
size
+
1
)
>>
1
);
d_hdr
=
0
;
//if (hwts)
// d_hdr = TX_DESC_WITH_OOB | (WRPC_FID << 12);
/* First we write status word (empty status for Tx) */
minic_txword
(
WRF_STATUS
,
0
);
/* Write the header of the frame */
ptr
=
(
uint16_t
*
)
hdr
;
for
(
i
=
0
;
i
<
hwords
;
++
i
)
minic_txword
(
WRF_DATA
,
ptr
[
i
]);
/* Write the payload without the last word (which can be one byte) */
ptr
=
(
uint16_t
*
)
payload
;
for
(
i
=
0
;
i
<
pwords
-
1
;
++
i
)
minic_txword
(
WRF_DATA
,
ptr
[
i
]);
//d_hdr |= TX_DESC_VALID | nwords;
/* Write last word of the payload (which can be one byte) */
if
(
size
%
2
==
0
)
minic_txword
(
WRF_DATA
,
ptr
[
i
]);
else
minic_txword
(
WRF_BYTESEL
,
ptr
[
i
]);
//*(volatile uint32_t *)(minic.tx_head) = d_hdr;
//*(volatile uint32_t *)(minic.tx_head + nwords) = 0;
/* Write also OOB if needed */
if
(
hwts
)
{
minic_txword
(
WRF_OOB
,
TX_OOB
);
minic_txword
(
WRF_OOB
,
WRPC_FID
);
}
/* Start sending the frame */
mcr
=
minic_readl
(
MINIC_REG_MCR
);
minic_writel
(
MINIC_REG_MCR
,
mcr
|
MINIC_MCR_TX_START
);
...
...
@@ -253,7 +276,6 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
hwts
->
ahead
=
0
;
hwts
->
nsec
=
counter_r
*
(
REF_CLOCK_PERIOD_PS
/
1000
);
// wrc_verbose("minic_tx_frame [%d bytes] TS: %d.%d valid %d\n", size, hwts->utc, hwts->nsec, hwts->valid);
minic
.
tx_count
++
;
}
...
...
include/minic.h
View file @
16a21407
...
...
@@ -14,6 +14,13 @@
#define WRPC_FID 0
#define WRF_DATA 0
#define WRF_OOB 1
#define WRF_STATUS 2
#define WRF_BYTESEL 3
#define TX_OOB 0x1000
void
minic_init
(
void
);
void
minic_disable
(
void
);
int
minic_poll_rx
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment