mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
e1000e: Implement system clock
The system clock is necessary to implement PTP features. While we are not implementing PTP features for e1000e yet, we do have a plan to implement them for igb, a new network device derived from e1000e, so add system clock to the common base first. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
69ff5ef847
commit
5fb7d14995
7 changed files with 103 additions and 5 deletions
|
@ -267,3 +267,28 @@ e1000x_read_tx_ctx_descr(struct e1000_context_desc *d,
|
|||
props->tcp = (op & E1000_TXD_CMD_TCP) ? 1 : 0;
|
||||
props->tse = (op & E1000_TXD_CMD_TSE) ? 1 : 0;
|
||||
}
|
||||
|
||||
void e1000x_timestamp(uint32_t *mac, int64_t timadj, size_t lo, size_t hi)
|
||||
{
|
||||
int64_t ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint32_t timinca = mac[TIMINCA];
|
||||
uint32_t incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK;
|
||||
uint32_t incperiod = MAX(timinca >> E1000_TIMINCA_INCPERIOD_SHIFT, 1);
|
||||
int64_t timestamp = timadj + muldiv64(ns, incvalue, incperiod * 16);
|
||||
|
||||
mac[lo] = timestamp & 0xffffffff;
|
||||
mac[hi] = timestamp >> 32;
|
||||
}
|
||||
|
||||
void e1000x_set_timinca(uint32_t *mac, int64_t *timadj, uint32_t val)
|
||||
{
|
||||
int64_t ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint32_t old_val = mac[TIMINCA];
|
||||
uint32_t old_incvalue = old_val & E1000_TIMINCA_INCVALUE_MASK;
|
||||
uint32_t old_incperiod = MAX(old_val >> E1000_TIMINCA_INCPERIOD_SHIFT, 1);
|
||||
uint32_t incvalue = val & E1000_TIMINCA_INCVALUE_MASK;
|
||||
uint32_t incperiod = MAX(val >> E1000_TIMINCA_INCPERIOD_SHIFT, 1);
|
||||
|
||||
mac[TIMINCA] = val;
|
||||
*timadj += (muldiv64(ns, incvalue, incperiod) - muldiv64(ns, old_incvalue, old_incperiod)) / 16;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue