This is from IRS publication 225, page 17;
https://www.irs.gov/pub/irs-pdf/p225.pdf
Elected Farm Income (EFI) EFI is the amount of income from your farming business that you elect to have taxed at base year rates. You can designate as EFI any type of income attributable to your farming business. However, your EFI can't be more than your taxable income, and any EFI from a net capital gain attributable to your farming business can't be more than your total net capital gain. Income from your farming business is the sum of any farm income or gain minus any farm expenses or losses allowed as deductions in figuring your taxable income. However, it doesn't include gain or loss from the sale or other disposition of land, or from the sale of development rights, grazing rights, and other similar rights.
Also see instructions for schedule J;
https://www.irs.gov/pub/irs-pdf/i1040sj.pdf