require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_IF_JMEVAR_H)) {
    eval 'sub _IF_JMEVAR_H () {1;}' unless defined(&_IF_JMEVAR_H);
    eval 'sub JME_TX_RING_CNT () {384;}' unless defined(&JME_TX_RING_CNT);
    eval 'sub JME_RX_RING_CNT () {256;}' unless defined(&JME_RX_RING_CNT);
    eval 'sub JME_TX_RING_ALIGN () {16;}' unless defined(&JME_TX_RING_ALIGN);
    eval 'sub JME_RX_RING_ALIGN () {16;}' unless defined(&JME_RX_RING_ALIGN);
    eval 'sub JME_TSO_MAXSEGSIZE () {4096;}' unless defined(&JME_TSO_MAXSEGSIZE);
    eval 'sub JME_TSO_MAXSIZE () {(65535+ $sizeof{\'struct ether_vlan_header\'});}' unless defined(&JME_TSO_MAXSIZE);
    eval 'sub JME_MAXTXSEGS () {32;}' unless defined(&JME_MAXTXSEGS);
    eval 'sub JME_RX_BUF_ALIGN () {$sizeof{ &uint64_t};}' unless defined(&JME_RX_BUF_ALIGN);
    eval 'sub JME_SSB_ALIGN () {16;}' unless defined(&JME_SSB_ALIGN);
    eval 'sub JME_ADDR_LO {
        my($x) = @_;
	    eval q((( &uint64_t) ($x) & 0xffffffff));
    }' unless defined(&JME_ADDR_LO);
    eval 'sub JME_ADDR_HI {
        my($x) = @_;
	    eval q((( &uint64_t) ($x) >> 32));
    }' unless defined(&JME_ADDR_HI);
    eval 'sub JME_MSI_MESSAGES () {8;}' unless defined(&JME_MSI_MESSAGES);
    eval 'sub JME_MSIX_MESSAGES () {8;}' unless defined(&JME_MSIX_MESSAGES);
    eval 'sub JME_TX_DESC_HIWAT () {( &JME_TX_RING_CNT - ((( &JME_TX_RING_CNT) * 3) / 10));}' unless defined(&JME_TX_DESC_HIWAT);
    eval 'sub JME_JUMBO_FRAMELEN () {9216;}' unless defined(&JME_JUMBO_FRAMELEN);
    eval 'sub JME_JUMBO_MTU () {( &JME_JUMBO_FRAMELEN - $sizeof{\'struct ether_vlan_header\'} -  &ETHER_HDR_LEN -  &ETHER_CRC_LEN);}' unless defined(&JME_JUMBO_MTU);
    eval 'sub JME_MAX_MTU () {( &ETHER_MAX_LEN + $sizeof{\'struct ether_vlan_header\'} -  &ETHER_HDR_LEN -  &ETHER_CRC_LEN);}' unless defined(&JME_MAX_MTU);
    eval 'sub JME_TX_FIFO_SIZE () {2000;}' unless defined(&JME_TX_FIFO_SIZE);
    eval 'sub JME_RX_FIFO_SIZE () {4000;}' unless defined(&JME_RX_FIFO_SIZE);
    eval 'sub JME_DESC_INC {
        my($x, $y) = @_;
	    eval q((($x) = (($x) + 1) % ($y)));
    }' unless defined(&JME_DESC_INC);
    eval 'sub JME_PROC_MIN () {10;}' unless defined(&JME_PROC_MIN);
    eval 'sub JME_PROC_DEFAULT () {( &JME_RX_RING_CNT / 2);}' unless defined(&JME_PROC_DEFAULT);
    eval 'sub JME_PROC_MAX () {( &JME_RX_RING_CNT - 1);}' unless defined(&JME_PROC_MAX);
    eval 'sub JME_TX_RING_ADDR {
        my($sc, $i) = @_;
	    eval q((($sc)-> ($jme_rdata->{jme_tx_ring_paddr}) + $sizeof{\'struct jme_desc\'} * ($i)));
    }' unless defined(&JME_TX_RING_ADDR);
    eval 'sub JME_RX_RING_ADDR {
        my($sc, $i) = @_;
	    eval q((($sc)-> ($jme_rdata->{jme_rx_ring_paddr}) + $sizeof{\'struct jme_desc\'} * ($i)));
    }' unless defined(&JME_RX_RING_ADDR);
    eval 'sub JME_TX_RING_SIZE () {($sizeof{\'struct jme_desc\'} *  &JME_TX_RING_CNT);}' unless defined(&JME_TX_RING_SIZE);
    eval 'sub JME_RX_RING_SIZE () {($sizeof{\'struct jme_desc\'} *  &JME_RX_RING_CNT);}' unless defined(&JME_RX_RING_SIZE);
    eval 'sub JME_SSB_SIZE () {$sizeof{\'struct jme_ssb\'};}' unless defined(&JME_SSB_SIZE);
    eval 'sub JME_CAP_FPGA () {0x1;}' unless defined(&JME_CAP_FPGA);
    eval 'sub JME_CAP_PCIE () {0x2;}' unless defined(&JME_CAP_PCIE);
    eval 'sub JME_CAP_PMCAP () {0x4;}' unless defined(&JME_CAP_PMCAP);
    eval 'sub JME_CAP_FASTETH () {0x8;}' unless defined(&JME_CAP_FASTETH);
    eval 'sub JME_CAP_JUMBO () {0x10;}' unless defined(&JME_CAP_JUMBO);
    eval 'sub JME_WA_CRCERRORS () {0x1;}' unless defined(&JME_WA_CRCERRORS);
    eval 'sub JME_WA_PACKETLOSS () {0x2;}' unless defined(&JME_WA_PACKETLOSS);
    eval 'sub JME_FLAG_MSI () {0x1;}' unless defined(&JME_FLAG_MSI);
    eval 'sub JME_FLAG_MSIX () {0x2;}' unless defined(&JME_FLAG_MSIX);
    eval 'sub JME_FLAG_DETACH () {0x4;}' unless defined(&JME_FLAG_DETACH);
    eval 'sub JME_FLAG_LINK () {0x8;}' unless defined(&JME_FLAG_LINK);
    eval 'sub CSR_WRITE_4 {
        my($_sc, $reg, $val) = @_;
	    eval q( &bus_space_write_4(($_sc)-> &jme_mem_bt, ($_sc)-> &jme_mem_bh, ($reg), ($val)));
    }' unless defined(&CSR_WRITE_4);
    eval 'sub CSR_READ_4 {
        my($_sc, $reg) = @_;
	    eval q( &bus_space_read_4(($_sc)-> &jme_mem_bt, ($_sc)-> &jme_mem_bh, ($reg)));
    }' unless defined(&CSR_READ_4);
    eval 'sub JME_MAXERR () {5;}' unless defined(&JME_MAXERR);
    eval 'sub JME_RXCHAIN_RESET {
        my($_sc) = @_;
	    eval q( &do { ($_sc)-> ($jme_cdata->{jme_rxhead}) =  &NULL; ($_sc)-> ($jme_cdata->{jme_rxtail}) =  &NULL; ($_sc)-> ($jme_cdata->{jme_rxlen}) = 0; }  &while (0));
    }' unless defined(&JME_RXCHAIN_RESET);
    eval 'sub JME_TX_TIMEOUT () {5;}' unless defined(&JME_TX_TIMEOUT);
    eval 'sub JME_TIMEOUT () {1000;}' unless defined(&JME_TIMEOUT);
    eval 'sub JME_PHY_TIMEOUT () {1000;}' unless defined(&JME_PHY_TIMEOUT);
    eval 'sub JME_EEPROM_TIMEOUT () {1000;}' unless defined(&JME_EEPROM_TIMEOUT);
    eval 'sub JME_TXD_RSVD () {1;}' unless defined(&JME_TXD_RSVD);
}
1;
